John_Reese
May 28th, 1999, 04:58 AM
Anyone know which mfc function is called when exiting via the "x" in top right?
|
Click to See Complete Forum and Search --> : Exit function question...MFC John_Reese May 28th, 1999, 04:58 AM Anyone know which mfc function is called when exiting via the "x" in top right? as_prabhu May 28th, 1999, 06:29 AM 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. John_Reese May 28th, 1999, 06:34 AM 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... Jason Teagle May 28th, 1999, 06:43 AM 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. John_Reese May 28th, 1999, 06:48 AM Thanks...I think that will help...(I'm completely new to windows programming, so I truly do appreciate it...) codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |