XForms: Problems with parameter passing within callbacks...

Humberto Cervantes Cuevas (hcc@hp9000a1.uam.mx)
Thu, 3 Sep 1998 12:35:00 -0600 (CST)

# To subscribers of the xforms list from Humberto Cervantes Cuevas <hcc@hp9000a1.uam.mx> :

Hello! I am quite new to this mailing list and maybe this problem has been
discussed before, but i would appreciate very much any solution...

I am programming in C++ and i have tried to encapsulate a form within a
class. Inside the declaration of the class, i have put the following
members (this is a simplified version):

class MyWindow
{
protected:
int winID;
FD_mywindow *mywin;
void CanvasHandler();

public:

bool OpenWindow();
bool ActivateWindow();
bool CloseWindow();

FD_mywindow *create_form_mywindow(void);

// Callbacks

void On_FILE_MENU(FL_OBJECT *ob,long data);

};

The form consists of a simple file menu.

The problem i have appears when assigning the callbacks.

Inside the member create_form_mywindow(void) i have the following lines:

FD_mywindow *create_form_mywindow(void)
{
.
.
.
fdui->FILE_MENU = obj = fl_add_menu(...);
fl_set_object_boxtype(obj,FL_FRAME_BOX);

fl_set_object_callback(obj,(FL_CALLBACKPTR)On_FILE_MENU,1);

.
.
.
}

As you can see i assign the pointer to the member function On_FILE_MENU to
the callback, the cast to FL_CALLBACKPTR is necessary otherwhise i get the
following error:

"a pointer to a bound function may only be used to call the function"

after compilation everything seems fine... I can press on the Menu item
and the function assigned to the callback is executed, BUT there is a
problem, when i want to read the argument i don't get the value i sent...

WHY ???

I noticed also that any of the attributes or variables of the class, like
winID in my example can't be read correctly inside any of the callback
functions but can be read correctly in any other of the functions before
and after the callback is executed.

I will appreciate very much any ideas on the solution to this problem.

Thank you very much.

Humberto Cervantes
hcc@hp9000a1.uam.mx

_________________________________________________
To unsubscribe, send the message "unsubscribe" to
xforms-request@bob.usuf2.usuhs.mil or see
http://bob.usuf2.usuhs.mil/mailserv/xforms.html
XForms Home Page: http://bragg.phys.uwm.edu/xforms
List Archive: http://bob.usuf2.usuhs.mil/mailserv/list-archives/