⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rectangle.cpp

📁 这是一个小型画板系统
💻 CPP
字号:
// Rectangle.cpp: implementation of the CRectangle class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "paint.h"
#include "Rectangle.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
IMPLEMENT_SERIAL(CRectangle,CObject,1)
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////


CRectangle::CRectangle()
{

}
CRectangle::CRectangle(CPoint ptFrom,CPoint ptTo,COLORREF color)
{
	pntStart = ptFrom;
	pntEnd = ptTo;
	pntColor = color;
}

CRectangle::~CRectangle()
{

}

void CRectangle::Draw(CDC *pDC)
{
	CPen lpen(PS_SOLID,1,pntColor);
	CPen *pOldPen=pDC->SelectObject(&lpen);
	pDC->SetROP2(R2_NOTXORPEN );		    //如果有旧线条就覆盖   
	pDC->MoveTo(pntStart);
	
	pDC->LineTo(pntEnd.x,pntStart.y);
	pDC->LineTo(pntEnd.x,pntEnd.y);
	pDC->LineTo(pntStart.x,pntEnd.y);
	pDC->LineTo(pntStart.x,pntStart.y);
}

void CRectangle::Serialize(CArchive &ar)
{
	CShape::Serialize(ar);
	if(ar.IsStoring())
	{
		ar<<pntStart<<pntEnd<<(DWORD)pntColor;
	}
	else
	{
		ar>>pntStart>>pntEnd>>(DWORD)pntColor;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -