In my demo kinda app
case WM_CLOSE:
DestroyWindow(hndl);
return 0;
and
case WM_CLOSE:
PostQuitMessage(0);
r
DestroyWindow
destroys the window (surprise) and posts a WM_DESTROY
(you'll also get a WM_NCDESTROY
) to the message queue. This is the default behaviour of WM_CLOSE
. However, just because a window was destroyed does not mean the message loop should end. This can be the case for having a specific window that ends the application when closed and others that do nothing to the application when closed (e.g., an options page).
PostQuitMessage
posts a WM_QUIT
to the message queue, often causing the message loop to end. For example, GetMessage
will return 0 when it pulls a WM_QUIT
out. This would usually be called in the WM_DESTROY
handler for your main window. This is not default behaviour; you have to do it yourself.