CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 1999
    Location
    Potsdam
    Posts
    110

    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.


  2. #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
  •  





Click Here to Expand Forum to Full Width

Featured