How-to exit an application correctly
|Exit Appli244968122001.zip||9/3/2020 3:45:00 PM||5,430|
This article demonstrates how to exit an application cleanly with user prompting (if required) without using the END Statement.
Original Author: Slider
Too many programmers these days use the end statement in their programs and under certain conditions leave fragements behind in memory, the application doesn't shut down fully, or in extreme cases cause GPFs.
To unload applications correctly, the statement 'Unload Me' should be used. The 'Form_QueryUnload' event will be triggered and at this point we should ask the user what to do. The reason why we should put a "Save Changes" propmt in the 'Form_QueryUnload' event is that there is more than one way to close an application. If the System Shutdown is invoked, or the Close "X" button is pressed, then we can catch these events and give the user a chance to save thier work.
Attached are two framework applications to demostrate how to close A) SDI application and B) MDI application.
If you find this article & code useful, then please leave me a comment and I'll add more useful articles.
Comments on this post
No comments have been added for this post.
You must be logged in to make a comment.