As the title says, I did some researches.
And I found a pretty interesting situation that no WM message can destroy the window.
LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) {
switch (msg) {
case WM_CLOSE:
// DestroyWindow(hWnd);
break;
case WM_DESTROY:
// PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, msg, wParam, lParam);
}
return 0;
}
And the message loop:
while (GetMessage(&Msg, NULL, 0, 0) >= 0) {
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
Normally That WM_QUIT causes GetMessage to return 0 and end the while loop.
But here isn't.
So the question is how can I destroy the window coded like this? (not terminate the thread).
By the way, after browsing the ms docs, I noticed there's a function called EndTask, and it works well on the window above.
What it did?