PlanetSquires Forums

Support Forums => Other Software and Code => Topic started by: Nathan Durland on April 29, 2010, 10:06:18 AM

Title: Program Cleanup
Post by: Nathan Durland on April 29, 2010, 10:06:18 AM
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.
Title: Re: Program Cleanup
Post by: Paul Squires on April 29, 2010, 10:27:45 AM
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).

Title: Re: Program Cleanup
Post by: Nathan Durland on April 29, 2010, 03:09:34 PM
Cool.  Thx for the information.