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

📄 line.cpp

📁 VC面向对象的学习教程
💻 CPP
字号:
// Line.cpp: implementation of the CLine class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "My.h"
#include "Line.h"

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

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

IMPLEMENT_SERIAL(CLine, CObject, 1)
CLine::CLine(POINT from, POINT to, COLORREF color, int width)
{
	m_pointFrom = from;
	m_pointTo   = to;
	m_colorLine = color;
	m_nWidth    = width;
}
CLine& CLine::operator =(CLine& line)
{
	m_pointFrom = line.m_pointFrom;
	m_pointTo	= line.m_pointTo;
	m_colorLine	= line.m_colorLine;
	m_nWidth	= line.m_nWidth;
	return *this;
}
void CLine::Serialize(CArchive &ar)
{
		if(ar.IsStoring())
		ar << m_pointFrom << m_pointTo << m_colorLine << m_nWidth;
		else
		ar >> m_pointFrom >> m_pointTo >> m_colorLine >> m_nWidth;
}
void CLine::DrawLine(CDC *pDC)
{
		CPen penNew, *ppenOld;
	penNew.CreatePen(PS_SOLID, m_nWidth, m_colorLine);
		ppenOld = pDC->SelectObject(&penNew);
	pDC->MoveTo(m_pointFrom);
		pDC->LineTo(m_pointTo);
	pDC->SelectObject(ppenOld);
}

⌨️ 快捷键说明

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