Original Post
Hi,
im developing a windows wrapper class, and everything works fine, except for
one thing :-/
This is my static callback function to handle the window procedure, it does
get called, but when i try to use GetWindowLong, it always returns 0. Anyone
else had this problem? Or know a better way to get a pointer to a window?
Ive checked out the article on this site, and im doing pretty much exactly the same thing, so i dont understand why its not working?
-------
CBaseWindow* pWnd = NULL;
// 1) WM_GETMINMAXINFO 0x0024 (36)
// 2) WM_NCCREATE 0x0081 (129)
if (msg == WM_NCCREATE)
{
// get the pointer to the window from lpCreateParams which was set in CreateWindow
SetWindowLong(hWnd, GWL_USERDATA, (long)((LPCREATESTRUCT(lParam))->lpCreateParams));
}
// get the pointer to the window
//pWnd = GetObjectFromWindow(hWnd);
pWnd = (CBaseWindow *)GetWindowLong(hWnd, GWL_USERDATA);
// if we have the pointer, go to the message handler of the window
// else, use DefWindowProc
if (pWnd)
return pWnd->MessageHandler(msg, wParam, lParam);
else
return DefWindowProc(hWnd, msg, wParam, lParam);