Hello,
Though I have consulted MSDN and Win32 Programmer's Reference,I am not still very clear about the
difference between the two messages:WM_CLOSE & WM_DESTROY.In code I have read,some use WM_CLOSE
as a signal of terminating a dialog and some else use WM_DESTROY.
So would someone tell me the difference between the two messages and the exact usage of them,thanks!
Posted on 2003-09-21 21:06:59 by allegretto
Hi allegretto,
I believe WM_CLOSE is sent to the window procedure before the window is removed from the screen. WM_DESTROY is sent to the window procedure after the window has been removed from the screen.
Posted on 2003-09-21 21:41:35 by bgong68
Hello allegretto,

This is from the SDK:

You can use the DestroyWindow function to destroy a window. Typically, an application sends the WM_CLOSE message before destroying a window, giving the window the opportunity to prompt the user for confirmation before the window is destroyed. A window that includes a window menu automatically receives the WM_CLOSE message when the user clicks Close from the window menu. If the user confirms that the window should be destroyed, the application calls DestroyWindow. The system sends the WM_DESTROY message to the window after removing it from the screen. In response to WM_DESTROY, the window saves its data and frees any resources it allocated. A main window concludes its processing of WM_DESTROY by calling the PostQuitMessage function to quit the application.


hope you find this helpful, best regards,

czDrillard
Posted on 2003-09-21 23:12:55 by czDrillard
Thanks!
Posted on 2003-09-22 08:11:03 by allegretto