OWLNext 7.0
Borland's Object Windows Library for the modern age
|
Users usually close a Windows application by choosing File|Exit or pressing Alt+F4.
To give the user a chance to save any open files, it's important that the application be able to intercept such an attempt.
TApplication lets you do that.
TApplication and all window classes have or inherit the member function CanClose. Whenever an application object tries to shut down, it queries the main window's and document manager's CanClose function. (The exception is when dialog boxes are canceled by the user's clicking the Cancel button or pressing the Esc key, in which case the dialog is simply destroyed, bypassing the CanClose function.) If either the main window or document manager object has children, it calls the CanClose function for each child. In turn, each child calls the CanClose function of each of its children, if any, and so on.
The CanClose function gives each object a chance to prepare to be shut down. It also gives the object a chance to abort to the shutdown if necessary. When the object has completed its clean-up procedure, its CanClose function should return true.
If any of the CanClose functions called returns false, the shut-down procedure is aborted.