I am trying to register a custom control, using RegisterClassex API which needs to be passed a WNDCLASSEX structure.
One member of WNDCLASSEX is the adress of the WndProc of the control.
I implemented the WndProc as a method of my custom control. How do I assign the address of this class method to the member of the WNDCLASSEX structure?
I recall having seen somewhere that one must implement WNDPROC as a static method. How can this be implemented in AURORA? Is there a work around?
I am at aloss. Any help would be appreciated.
If you just want to access class instance members when WndProc is called then use a window property to save off a pointer to your class instance.
Class methods have a 1st parameter called 'this' which is a pointer to the current instance of a class. Windows doesn't know about classes so would not call your method correctly as the parameter count would be wrong.
If you have the sources look at 'instance.src'
When a window is created in Aurora a WNDCLASSEX structure is filled in with the address of a regular function as the WndProc. I use SetWindowLong to save of the pointer to the current instance and when windows calls my WndProc I retrieve that pointer as such:
SUB DefaultHandler(hwnd as UINT, uMsg as UINT, wParam as UINT, lParam as UINT),INT
unsigned int result;
unsigned word atom;
atom = GetClassWord(hwnd,-32);
CWindow *pWnd;pWnd = NULL;
result = 0;
pWnd = GetWindowLongA(hwnd,0)
pWnd = 0;
Further down in the function I call a method in that instance to further process messages in an OOP way:
result = *pWnd.WndProc(uMsg,wParam,lParam);
Paul, thanks for the speedy response.
I guess I'll do this part as a non OOP SUB.
Wish there was a more elegant way though :-[
What I gave you was a way to redirect it to the OOP sub.
You have to remember that Windows itself is API based and doesn't know anything about OOP. So even in Microsofts own products, like MFC for VC++, they have to redirect messages like this to process them in the oop world.