MacArthur, Ian wrote:
> In the short term, I guess your handler function will just need to query
> the passed value, and maybe also look at "extern MSG fl_msg;" to see if
> this is the message you want or not, and then call some other function
> baseed on the value of fl_msg... Something like that?
Yes. Actually the way I builded up my app works, but
the thing with the global pointer bother me.
Here is a simplification of my code just to give you
an idea of what I'm talking about:
void *G_userdata = 0; //the global pointer
class MyApp : public Fl_Window
{
HWND hWnd; //a Windows window handle
...
public:
MyApp(w, h, const l*) : Fl_Window(w, h, l)
{
...
G_userdata = (void*)this; //initializes the global pointer
resizable(this);
show();
hWnd = fl_xid((Fl_Window*)this); //retrieve a valid Windows handle from the
app
...
Fl::add_handler(this->my_func_cb);
}
static int my_func_cb(int event);
void some_func();
};
int MyApp::my_func_cb(int event)
{
MyApp *This = (MyApp*)G_userdata;//retrieves the this pointer
switch(fl_msg.message) //parses the messages I'm interest with
{
case MY_MESSAGE:
This->some_func(); //and do something with it
return 1;
...
}
return 0;
}
int main (int argc, char ** argv)
{
MyApp myApp(500, 300, "My App");
return(Fl::run());
}
It works, but that global pointer annoy me.
May be I don't use add_handler the way it should be.
What do you think ?
>Could be - might be worth posting an STR to record this.
Forgive my ignorance but what a SRT is ?
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk