Defining the Working Data Used by the View

In the following procedure, you’ll add two member variables to class CScribbleView that store information about a stroke in progress.

Suggested Reading

To declare the new member variables

  1. In ClassView, double-click the icon for the CScribbleView class.

    This jumps you directly to the class definition (generated for you by AppWizard) in file ScribbleView.h.

  2. Add the following code right after the public Attributes section:
    protected:
    CStroke*   m_pStrokeCur;    // The stroke in progress
    CPoint     m_ptPrev;    // The last mouse pt in the stroke 
    // in progress
    

The New CScribbleView Member Variables

The code you just added declares two new protected member variables inside class CScribbleViewm_pStrokeCur and m_ptPrev.

You can view the new member variables in the ClassView pane of the Project Workspace window by saving the file and expanding the CScribbleView class icon.

The following table describes the new member variables.

CScribbleView Data Members

Member Description
m_pStrokeCur A pointer to the stroke currently being drawn.
m_ptPrev A CPoint object containing the previous mouse coordinates, from which a line will be drawn to the current coordinates.

The view uses these members to store the information it needs in order to record the points of a stroke in progress.