?? circle.cpp
字號:
// Arc.cpp: implementation of the CCircle class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "exp33_1.h"
#include "circle.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
IMPLEMENT_SERIAL(CCircle,CObject,1)
CCircle::CCircle():m_ptCenter(0,0)
{
m_color = RGB(0,0,0);
m_nRadius = 0;
}
CCircle::CCircle(int x,int y,int r):m_ptCenter(x,y)
{
m_nRadius = r;
}
CCircle::~CCircle()
{
}
void CCircle::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
// TODO: add storing code here
ar<<m_ptCenter<<m_nRadius<<m_color;
}
else
{
// TODO: add loading code here
ar>>m_ptCenter>>m_nRadius>>m_color;
}
}
void CCircle::Draw(CDC* pDC)
{
CPen pen(PS_SOLID,0,m_color);
CPen *oldPen;
oldPen = pDC->SelectObject(&pen);
CRect rect(m_ptCenter.x - m_nRadius,m_ptCenter.y - m_nRadius,m_ptCenter.x + m_nRadius,m_ptCenter.y + m_nRadius);
pDC->Ellipse(&rect);
pDC->SelectObject(oldPen);
}
void CCircle::Show(CDC* pDC,int y)
{
TEXTMETRIC tm;
pDC->GetTextMetrics(&tm);
int x = 0,l,cx;
cx = tm.tmAveCharWidth;
pDC->SetTextColor(m_color);
char st[15],ed[15];
wsprintf(st,"%d %d",m_ptCenter.x,m_ptCenter.y);
wsprintf(ed,"%d",m_nRadius);
pDC->TextOut(x,y,"Circle,Center:",l=strlen("Circle,Center:"));
x +=(l+1)*cx;
pDC->TextOut(x,y,st,l=strlen(st));
x += (l+1)*cx;
pDC->TextOut(x,y," Radius:",l=strlen(" Radius:"));
x += (l+1)*cx;
pDC->TextOut(x,y,ed,l=strlen(ed));
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -