arc.cpp

来自「mfc实验例题也是高教得配套资料 刚找到得 这部分应该是自学的内容」· C++ 代码 · 共 61 行

CPP
61
字号
// Arc.cpp: implementation of the CCircle class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "exp22_1.h"
#include "Arc.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);
}

⌨️ 快捷键说明

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