共用方式為


CDocument::DeleteContents

Called by the framework to delete the document's data without destroying the CDocument object itself.

virtual void DeleteContents( );

Remarks

It is called just before the document is to be destroyed. It is also called to ensure that a document is empty before it is reused. This is particularly important for an SDI application, which uses only one document; the document is reused whenever the user creates or opens another document. Call this function to implement an "Edit Clear All" or similar command that deletes all of the document's data. The default implementation of this function does nothing. Override this function to delete the data in your document.

Example

// This example is the handler for an Edit Clear All command.
void CExampleDoc::OnEditClearAll()
{
   DeleteContents();
   UpdateAllViews(NULL);   
}

void CExampleDoc::DeleteContents()
{
   // Re-initialize document data here.
}

Requirements

Header: afxwin.h

See Also

Reference

CDocument Class

Hierarchy Chart

CDocument::OnCloseDocument

CDocument::OnNewDocument

CDocument::OnOpenDocument

Other Resources

CDocument Members