Article View: comp.os.os2.programmer
Article #1292Re: WM_CLOSE, WM_DESTROY, WM_QUIT
From: Greg Altman
Date: Mon, 31 Aug 1992 23:41
Date: Mon, 31 Aug 1992 23:41
51 lines
2623 bytes
2623 bytes
shiva@well.sf.ca.us (Kenneth Porter) writes: : Just what are the relationship of the various window shutdown : messages? : : What should a window do to shut itself down without shutting down its : parent? WinDestroyWindow(hwndSelf)? Which message should handle saving : the window's state, WM_CLOSE or WM_DESTROY? : : My current understanding is that the client window proc should process : WM_CLOSE by invoking WinDestroyWindow() on its frame, and then return 0. : Any resource deallocation or state-saving is done while processing : WM_DESTROY. : : Ken Do not rely on any but WM_DESTROY message. This message is guaranteed to be received by your window BEFORE it is actually destroyed (or at the start of the destruction process). This is where all of your saving and other cleanup should be done. The window IS destroyed after the message is processed, and you cannot do anything about it. WM_CLOSE is passed to the FRAME window if the user selects the Close menu item from the system menu. What you do with the message is your affair. If you do not process this message, the frame window will get a WM_QUIT message and effectively end. You WILL get the WM_DESTROY message before the window is destroyed. You can stop the end of processing by intercepting the WM_CLOSE message and not passing it onto the default window procedure. WM_QUIT message should be sent to the window either in response to the WM_CLOSE message or to shut down the message reading queue. The result of this message is the termination of processing by the WinGetMsg() function. The usual scenario is: WM_DESTROY you are being destroyed and there is nothing you can do about it any more this message is guaranteed WM_CLOSE you have a choice of either refusing to shut your application down or of allowing the application to proceed (this message is not guaranteed before the window is gone) WM_QUIT you are being notified that the application or the system is about to end. You can ether destroy the message queue yourself, let the system do it for you or refuse to quit or this message is not guaranteed to continue with the shutdown -- Greg Altman grega@netcom.com
Technical Details
Message-ID:
<n7hntmc.grega@netcom.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!olivea!hal.com!decwrl!csus.edu!netcom.com!gregaReferences:
<BtvAMC.BL6@well.sf.ca.us>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!olivea!hal.com!decwrl!csus.edu!netcom.com!grega From: grega@netcom.com (Greg Altman) Newsgroups: comp.os.os2.programmer Subject: Re: WM_CLOSE, WM_DESTROY, WM_QUIT Message-ID: <n7hntmc.grega@netcom.com> Date: 31 Aug 92 23:41:35 GMT References: <BtvAMC.BL6@well.sf.ca.us> Organization: Netcom - Online Communication Services (408 241-9760 guest) Lines: 51