-
I have a global subclassing tool (Spyworks) and I need to know all the messages that are sent to a window when you press the "X" to close the window. I know WM_DESTROY is one of them, but I'm not sure of any others or in what order they are sent.
Thanks!
Jordan
-
The first one is WM_SYSCOMMAND with wParam = SC_CLOSE.
This only occurs if the user clicked the X or chose Close from the System Menu or pressed Alt+F4 to close. (Not if this happened through code)
This triggers the WM_CLOSE message. If you're using the Unload procedure to close the form, it will jump to WM_CLOSE (it didn't happen through X or SysMenu->Close or Alt+F4).
The WM_CLOSE message can be cancelled. (Like the events Unload and QueryUnload, which are actually WM_CLOSE in disguise)
If it is not cancelled, it invokes the WM_DESTROY message which nothing can stop (except crazy programs which like to crash). :rolleyes:
The WM_DESTROY message causes a complete and total destruction of the window, and invokes the WM_QUIT message.
At this state, the window no longer exists. The WM_QUIT message quits the internal message loop, usually causing the application to terminate.