Click to See Complete Forum and Search --> : Address of class method


kosta_m
April 27th, 2003, 02:15 AM
How can I send an address of a class method,
say class1::func()
to a callback function (writen in C) its parameter is a pointer to function.
THanx!

rxbagain
April 27th, 2003, 03:34 AM
U can use static function.

But be sure you have a way to get a psuedo this if you want to use the member variables.

The other way I do this is to place a dummy call to the function and then get the function address by using __asm. This is the code I made


class myclass {
public:
void myproc1(DWORD x)
{
return;
};

int myProc2(DWORD y) {
int myaddress;
__asm {
mov eax, offset MYPROC_FIN
mov ecx, [eax - 4]
add eax, ecx
mov [myaddress], eax
jmp MYPROC_FIN
}
myproc1(0);
MYPROC_FIN:
// u can now use the value of myaddress
....
....
};
};


Hope this will help you