> I have an access violation problem in my project, I made a > small example for demonstration:
You have the params wrong in your static callback method. You want something like this (note order of "v" and "o" params here!) static void cb(Fl_Widget *o, void *v) { ((A*)v)->cb_i(); } The way you have it, you are taking the "Fl_Widget*", which in this case will be pointing at the button that you clicked on, and are trying to call the "cb_i()" method on it, Sort of doing Fl_Button->cb_i(); Of course, "Fl_Button" does not have a "cb_i()" method, but since you have explicitly cast the "Fl_Button*" to be a "A*", the compiler assumes you know what you are doing and does not issue a warning at compile time... You only find out about this at run time... If you have the params the right way round, then the "void*" will be holding the "this" pointer for you're "A" class (set when you defined the button callback with "b->callback(cb,this);" And that will be what you are wanting, I'd guess. SELEX Galileo Ltd Registered Office: Sigma House, Christopher Martin Road, Basildon, Essex SS14 3EL A company registered in England & Wales. Company no. 02426132 ******************************************************************** This email and any attachments are confidential to the intended recipient and may also be privileged. If you are not the intended recipient please delete it from your system and notify the sender. You should not copy it or use it for any purpose nor disclose or distribute its contents to any other person. ******************************************************************** _______________________________________________ fltk mailing list fltk@easysw.com http://lists.easysw.com/mailman/listinfo/fltk