?? line.cpp
字號:
// Line.cpp: implementation of the CLine class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "exp32_2.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);
}
void CLine::Show(CDC* pDC,int y)
{
TEXTMETRIC tm;
pDC->GetTextMetrics(&tm);
int cx,l,x = 0;
cx = tm.tmAveCharWidth;
pDC->SetTextColor(m_color);
char st[15],ed[15];
wsprintf(st,"%d %d",m_ptStart.x,m_ptStart.y);
wsprintf(ed,"%d %d",m_ptEnd.x,m_ptEnd.y);
pDC->TextOut(x,y,"Line,start:",l=strlen("Line,start:"));
x += (l+1)*cx;
pDC->TextOut(x,y,st,l=strlen(st));
x += (l+1)*cx;
pDC->TextOut(x,y," End:",l=strlen(" End:"));
x += (l+1)*cx;
pDC->TextOut(x,y,ed,l=strlen(ed));
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -