My site is down unfortunately, so I can't link you to my article, but what I do is something like this:
// Header file: class CWindow{public: // ...private: static LRESULT CALLBACK StaticWndProc(HWND hwnd, UINT umsg, WPARAM wparam, LPARAM lparam); LRESULT WndProc(UINT umsg, WPARAM wparam, LPARAM lparam);protected: HWND m_hWnd; // ...};// Source file:LRESULT CALLBACK CWindow::StaticWndProc(HWND hwnd, UINT umsg, WPARAM wparam, LPARAM lparam){CWindow* pParent; if(umsg == WM_NCCREATE) { pParent = ((CREATESTRUCT*)lParam)->lpCreateParams; SetWindowLongPtr(hWnd, GWL_USERDATA, (LONG_PTR)pParent); } else { pParent = (CWindow*)GetWindowLongPtr(hWnd, GWL_USERDATA); } if(pParent) return pParent->WndProc(umsg, wparam, lparam); else return DefWindowProc(hWnd, usmg, wparam, lparam);}
And then you use StaticWndProc when you set up your WNDCLASS structure. You also need to use CreateWindowEx and pass this as the last parameter. Note that code is just off the top of my head and may not be accurate...