Share via


Adding the CStroke Class

In this topic, you will add the CStroke class declaration.

To add the CStroke class

  • Add the code shown below to ScribbleDoc.h and then save the file. The declaration for class CStroke must precede that for class CScribbleDoc, so it comes at the beginning of the file.

    /////////////////////////////////////////////////////
    // class CStroke
    // A stroke is a series of connected points in the Scribble drawing.
    // A Scribble document may have multiple strokes.
    class CStroke : public CObject
    {
    public:
    CStroke( UINT nPenWidth );
    
    protected:
    CStroke( );
    DECLARE_SERIAL( CStroke )
    
    // Attributes
    protected:
    UINT   m_nPenWidth;  // One width applies to entire stroke
    public:
    CArray<CPoint, CPoint>   m_pointArray;  // Series of connected                                                    // points
    
    // Operations
    public:
    BOOL DrawStroke( CDC* pDC );
    
    public:
    virtual void Serialize( CArchive& ar );
    };
    

This code declares a C++ class of stroke objects. You can examine the new CStroke class and its current list of member functions and variables in ClassView. The next topic, CStroke Member Functions and Variables, describes their purpose.