LRESULT CALLBACK WindowProc_Static(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam){ CWindow* pWindow; pWindow = (CWindow*)GetWindowLong(hwnd, GWL_USERDATA); return pWindow->WindowProc(hwnd, uMsg, wParam, lParam);}
You need to define two WndProcs, WindowProc_Static, and WindowProc, in your CWindow class. The static one is just that, and the other is a normal member function, which will have access to your member variables, etc., and it will do all the typical WndProc stuff.
Maybe I should write more to be clear, just in case:
//The CWindow class would look something like this:class CWindow{ public: //Stuff static LRESULT CALLBACK WindowProc_Static(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { CWindow* pWindow; pWindow = (CWindow*)GetWindowLong(hwnd, GWL_USERDATA); return pWindow->WindowProc(hwnd, uMsg, wParam, lParam); } LRESULT WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { //Standard message handling }};//////The CreateWindow call would look something like this assuming that CWindow is creating its own window):wc.//Blah...wc.lpfnWndProc = (WNDPROC)(CWindow::WindowProc_Static);wc.//Blah...CreateWindow(.../*Parameters*/, hInstance, this);////If CWindowFactory is actually making the call to CreateWindow(), then I suppose it''d be more like:CWindow* pWindow = new CWindow();CreateWindow(.../*Parameters*/, hInstance, pWindow);
Microsoft very likely designed that extra parameter for purposes very much like this purpose. Back in the day, it may have been used as a pointer to a structure, rather than a class, but it''s all the same concept, nonetheless.