PostQuitMessage() only posts a
WM_QUIT message to the message loop. The message loop may or may not receive the
WM_QUIT message as soon as the
PostQuitMesasge(0) is called.
Also as DestroyWindow does the destroying of the child windows, resources ...blah blah, there maybe a delay in that too. But I don't think it should take more than a couple of seconds. So the reason may depend on the delay you are experiencing. If it is only a small delay, then the reason must be what I explained. If not, then there must be resources still allocated to the calling thread.
Let me comment on the
WM_CLOSE message also. I see that you are explicitly calling
DestroyWindow at the
WM_CLOSE message. This is unnecessary. If you just let the
DefWindowProc handle it, it will automatically call the
WM_DESTROY Message. So either you can remove the
WM_CLOSE message handling part from the message loop ( if all that you do is call
DestroyWindow() )
//case WM_CLOSE: Removed the WM_CLOSE handling
//
case WM_DESTROY:
{
PostQuitMessage(0);
return 0;
}
return DefWindowProc (hWnd, msg, wParam, lParam) ; or
just insert a break like this.
case WM_CLOSE:
{
// Do the user notification and whatever else you want to do
//DestroyWindow(hwnd); // Commented out this function call
break; // break to the DefWindowProc function
}
case WM_DESTROY:
{
PostQuitMessage(0);
return 0;
}
return DefWindowProc (hWnd, msg, wParam, lParam) ;