ex22view.cpp

来自「一些VC++的经典实例」· C++ 代码 · 共 111 行

CPP
111
字号
// ex22View.cpp : implementation of the CEx22View class
//

#include "stdafx.h"
#include "ex22.h"

#include "ex22Doc.h"
#include "ex22View.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CEx22View

IMPLEMENT_DYNCREATE(CEx22View, CView)

BEGIN_MESSAGE_MAP(CEx22View, CView)
	//{{AFX_MSG_MAP(CEx22View)
		// NOTE - the ClassWizard will add and remove mapping macros here.
		//    DO NOT EDIT what you see in these blocks of generated code!
	//}}AFX_MSG_MAP
	// Standard printing commands
	ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CEx22View construction/destruction

CEx22View::CEx22View()
{
	// TODO: add construction code here

}

CEx22View::~CEx22View()
{
}

BOOL CEx22View::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

	return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CEx22View drawing

void CEx22View::OnDraw(CDC* pDC)
{
	CEx22Doc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	// TODO: add draw code for native data here
	CRect rect(0,0,pDoc->m_Radius*2,pDoc->m_Radius*2);//设定绘制圆形的矩形框
	CBrush BlueBrush(RGB(0,0,200)), *OldBrush;
	OldBrush=pDC->SelectObject(&BlueBrush);//SelectObject函数会返回系统的当前画刷
	pDC->Ellipse(&rect);
	pDC->SelectObject(OldBrush);//恢复默认画刷
	BlueBrush.DeleteObject();//释放画刷对象
}

/////////////////////////////////////////////////////////////////////////////
// CEx22View printing

BOOL CEx22View::OnPreparePrinting(CPrintInfo* pInfo)
{
	// default preparation
	return DoPreparePrinting(pInfo);
}

void CEx22View::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add extra initialization before printing
}

void CEx22View::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add cleanup after printing
}

/////////////////////////////////////////////////////////////////////////////
// CEx22View diagnostics

#ifdef _DEBUG
void CEx22View::AssertValid() const
{
	CView::AssertValid();
}

void CEx22View::Dump(CDumpContext& dc) const
{
	CView::Dump(dc);
}

CEx22Doc* CEx22View::GetDocument() // non-debug version is inline
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CEx22Doc)));
	return (CEx22Doc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CEx22View message handlers

⌨️ 快捷键说明

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