line.cpp
来自「学习VC的一些例子」· C++ 代码 · 共 63 行
CPP
63 行
// Line.cpp: implementation of the CLine class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "Day10.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()
{
}
CLine::~CLine()
{
}
CLine::CLine(CPoint ptFrom, CPoint ptTo, COLORREF crColor, UINT nWidth)
{
m_ptFrom = ptFrom;
m_ptTo = ptTo;
m_crColor = crColor;
m_nWidth = nWidth;
}
void CLine::Draw(CDC *pDC)
{
CPen lpen(PS_SOLID, m_nWidth, m_crColor);
CPen * pOldPen = pDC->SelectObject(&lpen);
pDC->MoveTo(m_ptFrom);
pDC->LineTo(m_ptTo);
pDC->SelectObject(pOldPen);
}
void CLine::Serialize(CArchive &ar)
{
CObject::Serialize(ar);
if (ar.IsStoring())
{
ar << m_ptFrom << m_ptTo << (DWORD) m_crColor << m_nWidth;
}
else
{
ar >> m_ptFrom >> m_ptTo >> (DWORD) m_crColor >> m_nWidth;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?