Using WizardBar to Override Base-Class Functions

In this task, you will use WizardBar to override OnOpenDocument and DeleteContents, which are needed for Scribble-specific initialization and cleanup.

WizardBar

To display WizardBar

  1. Right-click the unoccupied area next to the toolbars.

  2. From the menu, click WizardBar.

To use WizardBar to override functions

  1. From the WizardBar Class combo box, select CScribbleDoc.

  2. Click the arrow on the action button, located on the right side of WizardBar.

  3. From the action menu, click Add Virtual Function.

    The New Virtual Override dialog box appears.

  4. From the New Virtual Functions box, select OnOpenDocument. Click Add Handler.

    ClassWizard creates a starter definition for the function, highlighting the code so you can simply begin typing to override it. (You won’t type anything at this point.)

  5. Repeat step 4 for DeleteContents.

  6. Click OK and save ScribbleDoc.h and ScribbleDoc.cpp.

ClassWizard writes the overridden functions to ScribbleDoc.h. Practice using ClassView to jump to and examine the declaration in ScribbleDoc.h.

When you created the starter application, AppWizard added to ScribbleDoc.h the declaration for OnNewDocument and for Serialize. Here is the starter function handler code that ClassWizard added to ScribbleDoc.cpp (do not add this code):

BOOL CScribbleDoc::OnOpenDocument(LPCTSTR lpszPathName) 
{
if (!CDocument::OnOpenDocument(lpszPathName))
   return FALSE;

// TODO: Add your specialized creation code here

return TRUE;
}

void CScribbleDoc::DeleteContents() 
{
// TODO: Add your specialized code here and/or call the base class

CDocument::DeleteContents();
}

You will fill in the handler definitions for OnOpenDocument, OnNewDocument, and DeleteContents later, in Initializing and Cleaning Up.