Im trying to write hello world in win32 but when i close the main window, the app continues to run
My window procedure:
LRESULT CALLBACK MainWndProc(HWND hWnd, UINT msg, WPARAM wparam, LPARAM lparam)
{
switch (msg)
{
case WM_DESTROY:
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hWnd, msg, wparam, lparam);
}
Event loop:
while ((bret = GetMessage(&msg, hWndMain, 0, 0) != 0)
{
if (bret == -1)
{
DWORD error = GetLastError();
return 1;
}
TranslateMessage(&msg);
DispatchMessage(&msg);
}
Now, then i get WM_DESTROY by clicking on the top-right hand corner x, Instead of GetMessage() returning 0 to signify getting WM_QUIT, it instead returns -1 and GetLastError() whinges about error 1400, which is "invalid window handle" ...I'm perplexed.