Results 1 to 2 of 2

Thread: Messages sent to Window when "X" is Clicked

  1. #1
    Guest
    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

  2. #2
    Guru Yonatan's Avatar
    Join Date
    Apr 1999
    Location
    Israel
    Posts
    892
    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).
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width