Book Image

Microsoft Visual C++ Windows Applications by Example

By : Stefan Bjornander, Stefan Björnander
Book Image

Microsoft Visual C++ Windows Applications by Example

By: Stefan Bjornander, Stefan Björnander

Overview of this book

Table of Contents (15 chapters)
Microsoft Visual C++ Windows Applications by Example
Credits
About the Author
About the Reviewer
Preface
Index

The LineFigure Class


LineFigure is a direct sub class of Figure. Its task is to draw a line between two points, represented by m_ptFirst to m_ptLast. The fields are protected as they are reused by the ArrowFigure, which privately inherits LineFigure.

The default constructor is necessary due to serialization. The second constructor initializes the object when the user adds a new line to the drawing. The line's color is given, and so is its start point. Both the fields m_ptFirst and m_ptLast are set to the start point. When the line is created, it has the same start and end point.

The field m_eDragMode is originally set to CREATE_LINE by the constructor and to MODIFY_FIRST, MODIFY_LAST, or MOVE_LINE by Click, DoubleClick, or Inside depending whether the user clicks on one of the end points of the line or on the line itself. Observe that there is no enumeration constant for the case when the user misses the line. In that case, the functions simply return false and ModifyOrMove or Move will...