OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
Closing a Document

Like most other objects, TDocument provides functions that let you safely close and destroy the object.

TDocument::~TDocument() does a lot of cleanup. First it destroys its children and closes all open streams and other resources. Then, in order, it

  1. Detaches its attached template
  2. Closes all associated views
  3. Deletes its stream list
  4. Removes itself from its parent's list of children if the document has a parent or, if it doesn't have a parent, removes itself from the document manager's document list

In addition to a destructor, TDocument also provides a TDocument::CanClose() function to make sure that it's OK to close. CanClose first checks whether all its children can close. If any child returns false, CanClose returns false and aborts. If all child documents return true, CanClose calls the document manager function FlushDoc, which checks to see if the document is dirty. If the document is clean, FlushDoc and CanClose return true. If the document is dirty, FlushDoc opens a message box that prompts the user to either save the data, discard any changes, or cancel the close operation.

See Also