Well, here's the deal. I'm working on something like a very simple window manager for one of my projects.
I have a window class "SYS_Win" which represents a window and which can create itself. This class will eventually work as a base class to derive other window classes from, so I have a virtual WndProc function as a member of this class, which is to be registered with the class as usual.
This is the (abbreviated) class definition with the functions:
class SYS_Win
{
public:
bool Create(int nWidth, int nHeight, int nBits, bool bFullscreen, char *title);
...
private:
virtual LRESULT CALLBACK WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
...
};
This is the registration of the class, which is done inside the afforementioned Create() function, which is obviously also a member of SYS_Win.
wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
wc.lpfnWndProc = WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = GetModuleHandle(NULL);
wc.hIcon = LoadIcon(NULL, IDI_WINLOGO);
wc.hIconSm = LoadIcon(NULL, IDI_WINLOGO);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = NULL;
wc.lpszMenuName = NULL;
wc.lpszClassName = title;
wc.cbSize = sizeof(WNDCLASSEX);
And no, it doesn't make any different whether WndProc() is private, protected or public.
I can't even get it to work as a function pointer to a global function which is then associated with the class at runtime (though that may simple be me not being able to handle function pointers...)!
When I compile this I get something like
'=' : 'long (__stdcall SYS_Win::*)(struct HWND__ *,unsigned int,unsigned int,long)' can not convert to 'long (__stdcall *)(struct HWND__ *,unsigned int,unsigned int,long)'
And it doesn't let me typecast the function to WNDPROC either...
Thanks a lot in advance. I'm really stuck with this one.
-----------------------------
"Mr Sandman bring me a dream"
[edited by - MrSandman666 on May 5, 2003 3:17:38 PM]