im surprised you aren't having troubles with the procedure.
Usualy when you wrap procedures in classes you have to have 2... one statical and one non-statical
this what the statical procedure looks. When you create the window/dialog you have to pass a pointer of your class as the LPARAM.
static LRESULT CALLBACK StaticWndProc(HWND hwnd, UINT msg,
WPARAM wParam, LPARAM lParam)
if ( msg == WM_CREATE )
SetWindowLongPtr( hwnd, GWLP_USERDATA, (LONG)(LONG_PTR)((CREATESTRUCT *)lParam)->lpCreateParams );
CppApplication *targetApp = (CppApplication*)(LONG_PTR)GetWindowLongPtr( hwnd, GWLP_USERDATA );
if ( targetApp )
return targetApp->WndProc( hwnd, msg, wParam, lParam );
return DefWindowProc( hwnd, msg, wParam, lParam );
On the WM_CREATE Message you can set the pointer as the window long pointer and then retrieve it everytime you get a new message.
Works pretty well, I hope this helps.