OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
Modifying CanClose

CanClose should rarely return false.

Instead, CanClose should perform any actions necessary to return true. CanClose should return false only if it's unable to do something necessary for orderly shutdown, or if the user wants to keep the application running. For example, suppose you are creating a text editor. A possible procedure to follow in the CanClose member function would be to

  1. Check to see if the editor text had changed
  2. If so, prompt the user to ask whether the text should be saved before closing, using a message box with Yes, No, and Cancel buttons
  3. Check the return value from the message box: – If the user clicks Yes, save the file, return true from the CanClose function. – If the user clicks No, simply return true from the CanClose function without saving the file. – If the user clicks Cancel indicating that the user does not want to close the application yet, return false from the CanClose function without saving the file.