Creating a Save as on Program Exit

artwilkes used Ask the Experts™
I'm trying to create a saveon exit capability for an SDI program.  I currently use the destroywindow() function in the CMainFrame.  I need to be able to save when the user  clicks on the close X in the upper right hand corner of the program.  While this approach works, the MainFrame has already disappeared before the MessageBox appears with the should the file be saved question .  This looks unprofessional and I would like to have the message box appear before the MainFrame disappears. How do I do this?
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Use the FormClosing event on the form.


I'm not using a form I'm using a child window.  What function is available before the window is destroyed.  I've tried the destructor but that was to late.
You need to handle  onClose() or WM_CLOSE

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial