CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    May 1999
    Posts
    66

    Exit function question...MFC

    Anyone know which mfc function is called when exiting via the "x" in top right?


  2. #2
    Join Date
    May 1999
    Location
    India
    Posts
    98

    Re: Exit function question...MFC

    No MFC exit function is called when an application is exited by clicking the (X) button. Instead a WM_QUIT message is posted in the message queue in the "WM_CLOSE" message handler of the main window. On encountering the WM_QUIT message, the message loop is exited and the control is returned to the OS.


  3. #3
    Join Date
    May 1999
    Posts
    66

    Re: Exit function question...MFC

    Ok, that makes sense...but gives rise to two more questions. Is the same message posted with a double-click on the upper-right corner icon? If so, is it possible to override the process so that a mfc function IS called? We are having memory leaks on exit if not through the file-->exit menu path...Any and all help will be greatly appreciated...


  4. #4
    Join Date
    May 1999
    Location
    Farnborough, Hants, England
    Posts
    710

    Re: Exit function question...MFC

    Double-clicking the icon in the top-left or the cross in the top-right routes through WM_SYSCOMMAND (OnSysCommand() ) with an ID of SC_CLOSE. It then goes through WM_CLOSE, WM_DESTROY (OnDestroy() ) and WM_QUIT. The best place to catch this is OnDestroy(), because closing the window via any means (including File - Exit) goes through that route (since the window is always destroyed!) If this routine is not called, this is one reason for memory leaks - a window is not being destroyed.

    When your program exits, DevStudio usually lists the leaks and the lines at which the leaked objects were created. Although this isn't 100% useful, it may help to remove many of the problems.

    A common source of leaks is resources - calling GetXXX() but not ReleaseXXX(), or CreateXXX() but not DeleteXXX(), etc.



    --
    Jason Teagle
    [email protected]

  5. #5
    Join Date
    May 1999
    Posts
    66

    Re: Exit function question...MFC

    Thanks...I think that will help...(I'm completely new to windows programming, so I truly do appreciate it...)


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