Binding the Thick Line Command

When you finish adding OnEditClearAll, you will continue binding commands, using WizardBar.

Like the Clear All command, the Thick Line command will be handled by the document. Recall the discussion earlier in this lesson under Which Command-Target Class Gets the Handler?.

To bind Scribble’s Thick Line command

  1. Make sure that ScribbleDoc.cpp is active in the text editor.

  2. Repeat steps 2 through 7 of the procedure To create the starter handler for Scribble’s Clear All command, only this time for ID_PEN_THICK_OR_THIN, accepting the default member function name OnPenThickOrThin.

    ClassWizard creates the starter handler function at the end of ScribbleDoc.cpp.

  3. Replace the //TODO comment text with the following code:
    // Toggle the state of the pen between thin and thick.
    m_bThickPen = !m_bThickPen;
    
    // Change the current pen to reflect the new width.
    ReplacePen( );
    

The OnPenThickOrThin message handler first toggles the state of a Boolean variable, m_bThickPen. If the variable is now TRUE, the pen will be thick. Otherwise, it will be thin. The handler then calls a helper function, ReplacePen, to reset the current pen to the new width. (You will declare the m_bThickPen variable later in the lesson.)