Hi guys,
I have this little piece of code as a test and when I include it into my project it's acting very weird. First the window appears no problem it draws "Hello World!" etc... But when I close it, I don't seem to be receiving the WM_CLOSE neither the WM_DESTROY and the execution is stuck inside the GetMessage routine. The Window disappear on screen and everything seems normal on the PPC side, except that my program is hung and no WM_CLOSE or WM_DESTROY are passed to the application.
Thanx in advance for the help,
Kornalius
I have this little piece of code as a test and when I include it into my project it's acting very weird. First the window appears no problem it draws "Hello World!" etc... But when I close it, I don't seem to be receiving the WM_CLOSE neither the WM_DESTROY and the execution is stuck inside the GetMessage routine. The Window disappear on screen and everything seems normal on the PPC side, except that my program is hung and no WM_CLOSE or WM_DESTROY are passed to the application.
- Code:
void TestWnd (HINSTANCE hInstance)
{
WNDCLASS wc;
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = (WNDPROC)WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = 0;
wc.hCursor = 0;
wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wc.lpszMenuName = 0;
wc.lpszClassName = L"TestW";
RegisterClass(&wc;);
HWND h = CreateWindow(L"TestW", L"Caption", WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL);
ShowWindow(h, SW_SHOW);
UpdateWindow(h);
}
LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static SHACTIVATEINFO s_sai;
WNDCLASS wc;
wchar_t cn[MAX_PATH];
HDC hdc;
PAINTSTRUCT ps;
switch (message)
{
case WM_PAINT:
RECT rt;
hdc = BeginPaint(hWnd, &ps;);
GetClientRect(hWnd, &rt;);
DrawText(hdc, L"Hello World!", 12, &rt;, DT_SINGLELINE | DT_VCENTER + DT_CENTER);
EndPaint(hWnd, &ps;);
break;
case WM_CLOSE:
DestroyWindow(hWnd);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
case WM_ACTIVATE:
SHHandleWMActivate(hWnd, wParam, lParam, &s;_sai, FALSE);
break;
case WM_SETTINGCHANGE:
SHHandleWMSettingChange(hWnd, wParam, lParam, &s;_sai);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
TestWnd (hInstance);
MSG msg;
while (GetMessage(&msg;, NULL, 0, 0) > 0)
{
TranslateMessage(&msg;);
DispatchMessage(&msg;);
}
return msg.wParam;
}
Thanx in advance for the help,
Kornalius