They are completely different.
WM_CLOSE sent to the window when you click "X" or "Close" is selected from the window menu. If you catch this message, it is your call how to handle it - ignore it or really close the window. By default, WM_CLOSE passed to DefWindowProc causes the window to WM_CLOSE . When the window is destroyed, a WM_DESTROY message is sent. At this stage, unlike WM_CLOSE , you cannot stop the process, you can only do the necessary cleanup. But remember that when you catch WM_DESTROY just before all child windows are already destroyed. WM_NCDESTROY sent immediately after the destruction of all child windows.
WM_QUIT message is not associated with any windows (the hwnd value obtained from GetMessage is NULL, and the window procedure is not called). This message indicates that the message loop should be stopped and the application should be closed. When GetMessage reads WM_QUIT , it returns 0 to indicate this. Look at a typical fragment of a message loop - the loop continues, and GetMessage returns a nonzero value. WM_QUIT can be sent by the PostQuitMessage function. This function is usually called when the main window receives WM_DESTROY (see a typical fragment of a window procedure ).
adf88 Jul 01 '10 at 7:40 2010-07-01 07:40
source share