Advertisement
C_Volume2 Object Oriented Programming (OOP) #71717

How-to exit an application correctly

This article demonstrates how to exit an application cleanly with user prompting (if required) without using the END Statement.

AI

AI Summary: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Source Code
original-source
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.
Original Comments (3)
Recovered from Wayback Machine