line.cpp

来自「这是一个小型画板系统」· C++ 代码 · 共 65 行

CPP
65
字号
// Line.cpp: implementation of the CLine class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "paint.h"
#include "Line.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

IMPLEMENT_SERIAL(CLine,CObject,1)
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CLine::CLine()
{
	pntStart=CPoint(0,0);
	pntEnd = CPoint(0,0);
	
}

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

CLine::~CLine()
{

}

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

void CLine::Move(int xOffset, int yOffset)
{
	
}

void CLine::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 + =
减小字号Ctrl + -
显示快捷键?