I have put the windows procedure inside a class as a static member function and I get a pointer to the class containing the function using GetWindowLong(), and everything works fine, like calling member functions trough the pointer and reading variables through the pointer, but when I try to write through the pointer, I get an Access violation writing location... Does anyone know why?
LRESULT CALLBACK Win32Window::WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
// Get a pointer to the class which this window belongs to
if (msg != WM_CREATE)
w32Window = (Win32Window*)GetWindowLongPtr( hWnd, 0 );
CREATESTRUCT *cs = (CREATESTRUCT*)lParam;
w32Window = (Win32Window*)cs->lpCreateParams;
SetWindowLongPtr(hWnd, GWL_USERDATA, (LONG_PTR) w32Window);
w32Window->aMemberVariable = 0; // this causes a Access violation writing...
return DefWindowProc(hWnd, msg, wParam, lParam);