// Implementation of the elements classes #include "stdafx.h" #include "OurConstants.h" #include "Elements.h" // Add definitions for member functions here // CLine class constructor CLine::CLine( const CPoint& Start, const CPoint& End, const COLORREF& Color ) { m_StartPoint = Start; m_EndPoint = End; m_Color = Color; } // Draw a CLine object void CLine::Draw( CDC* pDC ) const { // Create a pen for this object and // initialize it to the object color and line width CPen aPen; if (!aPen.CreatePen(PS_SOLID, 1 /*m_Pen*/, m_Color )) { // Pen creation failed, Abort the program AfxMessageBox("Pen creation failed drawing a line", MB_OK ); AfxAbort(); } CPen* pOldPen = pDC->SelectObject( &aPen ); // Now draw the line pDC->MoveTo( m_StartPoint ); pDC->LineTo( m_EndPoint ); pDC->SelectObject( pOldPen ); // Restore the old pen }