ClassWizard adds several things to your source files when you use WizardBar to create a member function to handle a command:
The following figure shows the starter code for OnEditClearAll
.
The OnEditClearAll Function Template
To complete the OnEditClearAll handler function
OnEditClearAll
message-handler function. (Replace the highlighted //TODO comments.) DeleteContents( );
SetModifiedFlag();
UpdateAllViews( NULL );
SetModified Flag is a member function of class CDocument. It marks the document as changed so the framework will prompt the user to save the document when it closes.
The OnEditClearAll
message handler:
DeleteContents
to destroy the document’s stroke data.
Scribble’s version of DeleteContents
, from Lesson 8, Enhancing Views, overrides CDocument’s DeleteContents member function. (See To implement document cleanup.) The DeleteContents
member function iterates through the list of strokes. For each stroke, it gets the next stroke and calls the delete operator on it.
The document’s view is redrawn, this time with no data. UpdateAllViews takes a NULL argument because the document is modifying itself. The parameter is normally used to pass a pointer to the view that modified the document, but that doesn’t apply here.