GetArea chỉ đơn giản là tạo ra và trả về một đối tượng CRect với m_ptTopLeft và m_ptBottomRight như góc của nó. Nếu hình chữ nhật được đánh dấu, chúng tôi tăng khu vực xung quanh để bao gồm bốn hình vuông. | The Draw Application GetArea simply creates and returns a CRect object with m_ptTopLeft and m_ptBottomRight as its corners. If the rectangle is marked we increase the surrounding area in order to include the four squares. m_ptTopLeft m_ptTopLeft m_ptLast M p m_ptBottomRight CRect RectangleFigure GetArea const CRect rcRectangle m_ptTopLeft m_ptBottomRight if IsMarked - SQUARE_SIDE 2 SQUARE_SIDE 2 - SQUARE_SIDE 2 SQUARE_SIDE 2 return rcRectangle The EllipseFigure Class EllipseFigure manages an ellipse and is a direct sub class of TwoDimensionalFigure. It also privately inherits RectangleFigure from which it reuses a large part of functionality. The user may re-shape the ellipse by seizing the ellipse at its leftmost rightmost uppermost or lowermost point. The class reuses the fields m_ptTopLeft and m_ptBottomRight from RectangleFigure. Serialize DoubleClick Inside and GetArea simply call their counterparts in RectangleClass. class EllipseFigure public EllipseFigure public virtual TwoDimensionalFigure private RectangleFigure 200 Chapter 7 EllipseFigure const Color color const CPoint ptTopLeft BOOL bFilled EllipseFigure const EllipseFigure ellipse Figure Copy const void Serialize CArchive archive return RectangleFigure Serialize archive HCURSOR GetCursor const BOOL Click const CPoint ptMouse BOOL DoubleClick const CPoint ptMouse return RectangleFigure DoubleClick ptMouse BOOL Inside const CRect rcInside const return RectangleFigure Inside rcInside void MoveOrModify const CSize szDistance void Move const CSize szDistance return RectangleFigure Move szDistance void Draw CDC pDC const CRect GetArea const return RectangleFigure GetArea private enum CREATE_ELLIPSE MODIFY_LEFT MODIFY_RIGHT MODIFY_TOP MODIFY_BOTTOM MOVE_ELLIPSE m_eDragMode Just as in the rectangle case Click first decides if the user has clicked on one of the four end points the