Cast and methods
Now I found the answer a few topis beneath, but an important note : I'd like the method to be virtual
I'm writing a little library and badly need to subclass the program's window proc to catch some messages. I got the old Window Proc using GetWindowLong and wanted to set my own using SetWindowLong. But an problem has apeeared. I don't know how to cast the function to long/DWORD. It's probably quite important that it's a method, not a standard function. I've heard that methods have an additional hidden parameter which doesn't allow me to pass a method instead of a standard function, but I'm not sure. Finally, when I tried DefWindowLong instead of my method then, no errors were reported.
class A{
long WndProc(HWND a,UINT b,UINT c,LONG d);
void SetIt();
};
void A::SetIt()
{
SetWindowLong(window,GWL_HWN...,(long)WndProc);//error, cannot cast
}
thanks for help
Edited by - Caesar on December 30, 2001 1:25:14 PM
The problem is that WndProc is a member of a class. You should be able to do it with static members and passing the this pointer in extra window memory (or how shall I call this?)
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement