Hi again.
I have another issue trying to understand some examples. I'm looking at the sample scripts drawing buttons. Both the basic samples and those provided by marc2003 use the same constructor function. I'm clueless on this part :
this.draw = function (gr) {
if (this.state == ButtonStates.hide) return;
switch (this.state)
{
... <snip> ...
}
g_theme.DrawThemeBackground(gr, this.x, this.y, this.w, this.h);
gr.GdiDrawText(this.text, g_font, RGB(0,0,0), this.x, this.y, this.w, this.h, DT_CENTER| DT_VCENTER | DT_CALCRECT | DT_NOPREFIX);
}
The method defined here receives an argument called gr and uses it as an argument to g_theme.DrawThemeBackground. However, whenever a <button>.draw method is called in any sample i've seen, the argument passed to it is also simply gr. But nowhere i found a statement defining gr
I found a reference to gr in callbacks but it states it's invalid outside of two specific callbacks : on_tooltip_custom_paint and on_paint. Here it's used by drawAllButtons(gr) function.
Surely i'm missing something. I guess i could just copy-paste working scripts without wondering how they are working but this looks like a sure-way to big mistakes later on.
Also, there is also this gr.GdiDrawText() method used in the sample. According to what i understood from the doc this method belongs to an IGdiGraphics interface that fist has to be created by the method GetGraphics() of an IGdiBitmap interface, itself created by some methods of the "first-level" interfaces window or gdi. Again, i guess i missed something.
Can someone help me understand how this works?