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
OnPenThickOrThin
.ClassWizard creates the starter handler function at the end of ScribbleDoc.cpp.
// 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.)