RE: [Dev-C++] Static members for callbacks
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Ioannis V. <no...@ho...> - 2002-07-29 07:34:12
|
> -----Original Message----- > From: Abhijit Shylanath [mailto:mu...@gm...] > Sent: Monday, July 29, 2002 9:50 AM > To: Ioannis Vranos > Cc: Dev-C++ Mailing List > Subject: Re: [Dev-C++] Static members for callbacks > > > > > You can't use non-static methods for windows callbacks (like in > > > CreateThread(), SetWindowsHookEx()) which need you to suppply > > > a call-back > > > function. > > > > > > This is too Win32 to me. What do you mean by call-back > function. Can you > > provide a small concrete example? > > > Basically, typedef function_pointer call_back; > > For example, in CreateThread(), the args are: > > HANDLE CreateThread( > LPSECURITY_ATTRIBUTES lpThreadAttributes, // address of > thread security > attributes > DWORD dwStackSize, // initial thread stack size, in bytes > LPTHREAD_START_ROUTINE lpStartAddress, // address of > thread function > LPVOID lpParameter, // argument for new thread > DWORD dwCreationFlags, // creation flags > LPDWORD lpThreadId // address of returned thread identifier > ); > > Here, LPTHREAD_START_ROUTINE should be a function pointer to a 32-bit > returning (void *) accepting function, as in > > DWORD my_thread_proc(void *some_arg); > > where DWORD is, on Win32, unsigned long. Ok then you can use a regular function to call the appropriate member function. This regular function will accept also your object as a parameter. Ioannis * Ioannis Vranos * Programming pages: http://www.noicys.cjb.net * Alternative URL: http://run.to/noicys |