I wrote a main window class for a GUI system I am writing. In the constructor of the main window it creates a windows window using the CreateWindow() function. The window shows up fine as expected, however I can't grab the title bar and move it around the screen. It is completely frozen. Here is the code in the constructor.
//Set up window class
WNDCLASS wnd;
wnd.cbClsExtra = 0;
wnd.cbWndExtra = 0;
wnd.hCursor = LoadCursor(0, IDC_ARROW);
wnd.hIcon = LoadIcon(0, IDI_WINLOGO);
wnd.lpszMenuName = 0;
wnd.style = 0;
wnd.hbrBackground = 0;
wnd.lpfnWndProc = WndProc;
wnd.hInstance = GetModuleHandle(NULL);
wnd.lpszClassName = L"GtMainWindow";
//Register window class
RegisterClass(&wnd);
this->m_winID = CreateWindow(
L"GtMainWindow", /* Classname */
L"Windows App", /* Title Text */
WS_OVERLAPPEDWINDOW, /* default window */
CW_USEDEFAULT, /* Windows decides the position */
CW_USEDEFAULT, /* where the window ends up on the screen */
500, /* The programs width */
500, /* and height in pixels */
HWND_DESKTOP, /* The window is a child-window to desktop */
NULL, /* No menu */
GetModuleHandle(NULL), /* Program Instance handler */
NULL /* No Window Creation data */
);
ShowWindow(m_winID,SW_SHOW);
Here is the WinProc callback function
//WndProc function
LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) {
switch(msg) {
case WM_PAINT:
{
//GtWidget::PostPaint();
return 0;
}
case WM_CLOSE:
case WM_DESTROY:
{
PostQuitMessage(0);
GtApplication* ptrApp = GtApplication::GetAppInstancePtr();
ptrApp->Quit();
return 0;
}
}
return DefWindowProc(hWnd, msg, wParam, lParam);
}
Now I have a separate EventManager that contains all of the PeekMessage processing that resides inside the GtApplication. The question again is why is the window freezing and not responding to any title bar manipulation. I can't move it, minimize it, maximize it or close it. Any help would greatly be appreciated. Thank you in advance. Sincerely, Anthony Daniels
The problem was that the event processing loop was on a different thread from the window. Apparently this is forbidden. Once the event processing loop was moved to the main thread everything works fine.