home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / os / os2 / programm / 4615 < prev    next >
Encoding:
Internet Message Format  |  1992-08-31  |  2.5 KB

  1. Path: sparky!uunet!olivea!hal.com!decwrl!csus.edu!netcom.com!grega
  2. From: grega@netcom.com (Greg Altman)
  3. Newsgroups: comp.os.os2.programmer
  4. Subject: Re: WM_CLOSE, WM_DESTROY, WM_QUIT
  5. Message-ID: <n7hntmc.grega@netcom.com>
  6. Date: 31 Aug 92 23:41:35 GMT
  7. References: <BtvAMC.BL6@well.sf.ca.us>
  8. Organization: Netcom - Online Communication Services  (408 241-9760 guest)
  9. Lines: 51
  10.  
  11. shiva@well.sf.ca.us (Kenneth Porter) writes:
  12. : Just what are the relationship of the various window shutdown
  13. : messages?
  14. : What should a window do to shut itself down without shutting down its
  15. : parent?  WinDestroyWindow(hwndSelf)? Which message should handle saving
  16. : the window's state, WM_CLOSE or WM_DESTROY?
  17. : My current understanding is that the client window proc should process
  18. : WM_CLOSE by invoking WinDestroyWindow() on its frame, and then return 0.
  19. : Any resource deallocation or state-saving is done while processing
  20. : WM_DESTROY.
  21. : Ken
  22.  
  23. Do not rely on any but WM_DESTROY message. This message is guaranteed to
  24. be received by your window BEFORE it is actually destroyed (or at the start
  25. of the destruction process). This is where all of your saving and other
  26. cleanup should be done. The window IS destroyed after the message is 
  27. processed, and you cannot do anything about it.
  28.  
  29. WM_CLOSE is passed to the FRAME window if the user selects the Close
  30. menu item from the system menu. What you do with the message is
  31. your affair. If you do not process this message, the frame window will
  32. get a WM_QUIT message and effectively end. You WILL get the WM_DESTROY
  33. message before the window is destroyed.
  34.  
  35. You can stop the end of processing by intercepting the WM_CLOSE message
  36. and not passing it onto the default window procedure.
  37.  
  38. WM_QUIT message should be sent to the window either in response to the
  39. WM_CLOSE message or to shut down the message reading queue. The result
  40. of this message is the termination of processing by the WinGetMsg()
  41. function.
  42.  
  43. The usual scenario is:
  44.     WM_DESTROY    you are being destroyed and there is nothing
  45.             you can do about it any more
  46.             this message is guaranteed
  47.     WM_CLOSE    you have a choice of either refusing to
  48.             shut your application down or of allowing
  49.             the application to proceed (this message
  50.             is not guaranteed before the window is gone)
  51.     WM_QUIT        you are being notified that the application
  52.             or the system is about to end. You can ether
  53.             destroy the message queue yourself, let the
  54.             system do it for you or refuse to quit or
  55.             this message is not guaranteed
  56.             to continue with the shutdown
  57. -- 
  58. Greg Altman grega@netcom.com
  59.