简易画图板

上传:lanbo5529 浏览: 57 推荐: 0 文件:RAR 大小:8.23MB 上传时间:2019-01-01 20:59:36 版权申诉
较为完整的vc++ 画图程序 IMPLEMENT_SERIAL(CShape,CObject,1) IMPLEMENT_SERIAL(CLine,CShape,1) IMPLEMENT_SERIAL(CRectangle,CShape,1) IMPLEMENT_SERIAL(CCircle,CShape,1) IMPLEMENT_SERIAL(CCurve,CShape,1) IMPLEMENT_SERIAL(CEllipse,CShape,1) CShape::CShape(void) { } CShape::~CShape(void) { } CRect CShape::GetBoundRect() { CRect BoundingRect; // Object to store bounding rectangle BoundingRect = m_EnclosingRect; // Store the enclosing rectangle // Increase the rectangle by the pen width BoundingRect.InflateR ect(m_Pen, m_Pen); return BoundingRect; // Return the bounding rectangle } void CShape::Serialize(CArchive& ar) { CObject::Serialize(ar); if(ar.IsStoring()) { arm_Pen; } } CLine::CLine(void) { } CLine::~CLine(void) { } // CLine class constructor CLine::CLine(CPoint Start, CPoint End, COLORREF aColor,int PenWidth) { m_StartPoint = Start; // Set line start point m_EndPoint = End; // Set line end point m_Color = aColor; //m_Brush=aBrush;// Set line color m_Pen = PenWidth; // Set pen width // Define the enclosing rectangle m_EnclosingRect = CRect(Start, End); m_EnclosingRect.NormalizeRect(); } // Draw a CLine object void CLine::Draw(CDC* pDC) { // Create a pen for this object and // initialize it to the object color and line width of 1 pixel CPen aPen; if(!aPen.CreatePen(PS_SOLID, m_Pen, m_Color)) { // Pen creation failed. Abort the program AfxMessageBox(_T("Pen creation failed drawing a line"), MB_OK); AfxAbort(); } CPen* pOldPen = pDC->SelectObject(&aPen;); // Select the pen // Now draw the line pDC->MoveTo(m_StartPoint); pDC->LineTo(m_EndPoint); pDC->SelectObject(pOldPen); // Restore the old pen } void CLine::Serialize(CArchive& ar) { CShape::Serialize(ar); if(ar.IsStoring()) { arm_EndPoint; } } ect(m_Pen, m_Pen); return BoundingRect; // Return the bounding rectangle } void CShape::Serialize(CArchive& ar) { CObject::Serialize(ar); if(ar.IsStoring()) { arm_Pen; } } CLine::CLine(void) { } CLine::~CLine(void) { } // CLine class constructor CLine::CLine(CPoint Start, CPoint End, COLORREF aColor,int PenWidth) { m_StartPoint = Start; // Set line start point m_EndPoint = End; // Set line end point m_Color = aColor; //m_Brush=aBrush;// Set line color m_Pen = PenWidth; // Set pen width // Define the enclosing rectangle m_EnclosingRect = CRect(Start, End); m_EnclosingRect.NormalizeRect(); } // Draw a CLine object void CLine::Draw(CDC* pDC) { // Create a pen for this object and // initialize it to the object color and line width of 1 pixel CPen aPen; if(!aPen.CreatePen(PS_SOLID, m_Pen, m_Color)) { // Pen creation failed. Abort the program AfxMessageBox(_T("Pen creation failed drawing a line"), MB_OK); AfxAbort(); } CPen* pOldPen = pDC->SelectObject(&aPen;); // Select the pen // Now draw the line pDC->MoveTo(m_StartPoint); pDC->LineTo(m_EndPoint); pDC->SelectObject(pOldPen); // Restore the old pen } void CLine::Serialize(CArchive& ar) { CShape::Serialize(ar); if(ar.IsStoring()) { arm_EndPoint; } }
上传资源
用户评论