Original Post
Up until now I believed that the first message sent to my WndProc() function was WM_NCCREATE, but it seems that it isn't (I don't know which one is, I just know that its equal to 36). Does anybody know what the very first message sent to a window procedure is? I'm making a window class with a window procedure as a method of the class. And when it tries to call the procedure, I get an access violation. Here's my code: I use the debugger in MSVC++ 6 and I have a breakpoint in StaticWndProc. I step through it and it skips over my WM_NCCREATE case. Any help would be appreciated, thanks!
//Window creation
bool Window::Create()
{
WNDCLASS WndClass;
ZeroMemory(&WndClass, sizeof(WNDCLASS));
WndClass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
WndClass.hCursor = LoadCursor(0, IDC_ARROW);
WndClass.hIcon = LoadIcon(0, IDI_APPLICATION);
WndClass.hInstance = GetModuleHandle(0);
WndClass.lpfnWndProc = StaticWndProc;
WndClass.lpszClassName = "DFTLIB::Window";
if(!RegisterClass(&WndClass))
return false;
m_Handle = CreateWindowEx(0, "DFTLIB::Window", m_Caption.c_str(), m_nStyle, m_iX, m_iY, m_nWidth, m_nHeight, 0, 0, GetModuleHandle(0), this);
if(!m_Handle)
return false;
return true;
}
// My static window procedure
LRESULT CALLBACK Window::StaticWndProc(HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam)
{
Window* pWnd = 0;
switch(nMsg)
{
case WM_NCCREATE:
{
pWnd = (Window*)(((LPCREATESTRUCT)lParam)->lpCreateParams);
SetWindowLong(hWnd, GWL_USERDATA, (long)pWnd);
//pWnd is still zero here
break;
}
}
pWnd = (Window*)GetWindowLong(hWnd, GWL_USERDATA);
WINDOWDATA WndData;
WndData.Handle = hWnd;
WndData.Message = nMsg;
WndData.wParam = wParam;
WndData.lParam = lParam;
if(pWnd->m_HandlerFunc(&WndData))
return 0;
return DefWindowProc(hWnd, nMsg, wParam, lParam);
}