Basic Question:
How do you use a C++ method as a callback function?
There are several situations within the Palm SDK which require the
inclusion of a callback function in a an API method call. Of particular
interest to me is the case where I try to set up an event handler for a
form. I am attempting to use an objects method as the event handler but
the compiler seems to be unable to resolve something. Here is a
simplification of the scenario:
Class A {
private:
FormPtr myFormPtr; //pointer to a
valid form
public:
void setup(); //method trying to
setup an event handler for the form
Boolean handleEvent(EventPtr eventPtr) //method which is
the event handler for the form
}
void A::setup() {
//FrmGotoForm stuff..
FrmSetEventHandler(myFormPtr, handleEvent));
//<----------Error occurs here
//do some other stuff
}
Boolean A::handleEvent(EventPtr eventPtr) {
Boolean handled = false;
//handle the incoming events
return handled
}
The specific error is as follows:
Error : cannot convert
'unsigned char (A::*)(const void *const , EventType *)' to
'unsigned char (*const )(EventType *)'
Service.cpp line 150 FrmSetEventHandler(myFormPtr,
handleEvent));
Any and all help is greatly appreciated! I have tried various
forms of specifying the pointer like this->handleEvent, and what not, but
I can't seem to make this work.
Sincerely,
Noah J. Ternullo
--------------------------------------------------------------------------------
Noah J. Ternullo [EMAIL PROTECTED]
--------------------------------------------------------------------------------
"As a matter of constitutional tradition, in the absence of evidence to the
contrary, we presume that governmental regulation of the content of speech
is more likely to interfere with the free exchange of ideas than to
encourage it." - Supreme Court Justice John Paul Stevens
--------------------------------------------------------------------------------
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palm.com/devzone/mailinglists.html