Program Cleanup

Started by Nathan Durland, April 29, 2010, 10:06:18 AM

Previous topic - Next topic

Nathan Durland

My program has a main form, and all other forms are opened/closed from there.  When the user is done and closes the main form, I want to do a little cleanup.  ("will the last one out please turn off the lights?").   The other forms in the program are opened modal from the main form, so as I understand it the main form can't be closed before any of the others.

Where is the best place to put the cleanup code -- MAINFORM_WM_DESTROY or MAINFORM_WM_CLOSE?

Thanks in advance.

Paul Squires

Hi Nathan,

Everything that I have read on this subject suggests to put your clean up code in MAINFORM_WM_DESTROY. Some examples that I see put clean up code after the end of the main message loop but Rector & Newcomer do not recommend that. You'd be safe with using WM_DESTROY or even WM_NCDESTROY (if you're not saving window position information).

Paul Squires
PlanetSquires Software

Nathan Durland

Cool.  Thx for the information.