|
-
April 9th, 1999, 09:04 AM
#1
Help! 'x' box at top right of window
Hello. When you click on the 'x' box on the top right of the window, it sends a WM_DESTROY message. In the OnDestroy function, I have my code calling SetModifiedFlag(TRUE), however, I never get a prompt asking to save the document. What would be the correct way to save information from a form upon exiting from the form? Thanks.
-
April 9th, 1999, 06:16 PM
#2
Re: Help! 'x' box at top right of window
Well, the correct way is to call SetModifiedFlag(true) at the point where the user modifies the data.
But, if you just want to force the user to always be prompted, call SetModifiedFlag(true) in the WM_CLOSE handler, not the WM_DESTROY handler. There is much confusion in the world about the meaning of these two messages.
WM_CLOSE is sent by Windows to say, "I have been asked to close this window - is that okay with you?". If it's okay with you, your OnClose( ) handler should call the base class CWnd::OnClose( ) method; that method will, in turn, post a WM_DESTROY message. (If it's not okay with you, simply don't call the base method.)
WM_DESTROY is Windows' way of saying, "This window is closing, whether you like it or not. Do whatever cleanup you need to do, because this is your last chance!"
HTH.
LA Leonard - Definitive Solutions, Inc.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|