SetWindowLong using a class member function?
-
Hi I have the following situation: SetWindowLong(hWnd,GWL_WNDPROC,(LONG)MyOwnWndProc); MyOwnWndProc is a member function of a class I've made. Now I was wondering if it's possible to somehow convert a pointer to the function or something to a LONG. In its current state this won't compile. I've already tried making a class member pointer, and tried to convert that to a LONG, but alas no go. And no, I don't want to use a non-class function. I really need to know if it's possible with a class function. Many thanks in advance, DanglingDude
-
Hi I have the following situation: SetWindowLong(hWnd,GWL_WNDPROC,(LONG)MyOwnWndProc); MyOwnWndProc is a member function of a class I've made. Now I was wondering if it's possible to somehow convert a pointer to the function or something to a LONG. In its current state this won't compile. I've already tried making a class member pointer, and tried to convert that to a LONG, but alas no go. And no, I don't want to use a non-class function. I really need to know if it's possible with a class function. Many thanks in advance, DanglingDude
Its possible with class member functions. Try this LRESULT CALLBACK YourClass::MyOwnWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { } and then use SetWindowLong(hWnd,GWL_WNDPROC,(LONG)MyOwnWndProc); "A robust program is resistant to errors -- it either works correctly, or it does not work at all; whereas a fault tolerant program must actually recover from errors."
-
Hi I have the following situation: SetWindowLong(hWnd,GWL_WNDPROC,(LONG)MyOwnWndProc); MyOwnWndProc is a member function of a class I've made. Now I was wondering if it's possible to somehow convert a pointer to the function or something to a LONG. In its current state this won't compile. I've already tried making a class member pointer, and tried to convert that to a LONG, but alas no go. And no, I don't want to use a non-class function. I really need to know if it's possible with a class function. Many thanks in advance, DanglingDude
DanglingDude wrote: And no, I don't want to use a non-class function. I really need to know if it's possible with a class function.
MyOwnWndProc()
would need to be astatic
member in order for this to work.
Five birds are sitting on a fence. Three of them decide to fly off. How many are left?
-
Its possible with class member functions. Try this LRESULT CALLBACK YourClass::MyOwnWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { } and then use SetWindowLong(hWnd,GWL_WNDPROC,(LONG)MyOwnWndProc); "A robust program is resistant to errors -- it either works correctly, or it does not work at all; whereas a fault tolerant program must actually recover from errors."