|
-
May 28th, 1999, 04:58 AM
#1
Exit function question...MFC
Anyone know which mfc function is called when exiting via the "x" in top right?
-
May 28th, 1999, 06:29 AM
#2
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.
-
May 28th, 1999, 06:34 AM
#3
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...
-
May 28th, 1999, 06:43 AM
#4
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.
-
May 28th, 1999, 06:48 AM
#5
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|