line.cpp
来自「mfc实验例题也是高教得配套资料 刚找到得 这部分应该是自学的内容」· C++ 代码 · 共 58 行
CPP
58 行
// Line.cpp: implementation of the CLine class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "exp22_1.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():m_ptStart(0,0),m_ptEnd(0,0)
{
m_color = RGB(0,0,0);
}
CLine::CLine(int x1,int y1,int x2,int y2):m_ptStart(x1,y1),m_ptEnd(x2,y2)
{
}
CLine::~CLine()
{
}
void CLine::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
// TODO: add storing code here
ar<<m_ptStart<<m_ptEnd<<m_color;
}
else
{
// TODO: add loading code here
ar>>m_ptStart>>m_ptEnd>>m_color;
}
}
void CLine::Draw(CDC* pDC)
{
CPen pen(PS_SOLID,0,m_color);
CPen *oldPen;
oldPen = pDC->SelectObject(&pen);
pDC->MoveTo(m_ptStart);
pDC->LineTo(m_ptEnd);
pDC->SelectObject(oldPen);
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?