ex19view.cpp

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

CPP
157
字号
// ex19View.cpp : implementation of the CEx19View class
//

#include "stdafx.h"
#include "ex19.h"

#include "ex19Doc.h"
#include "ex19View.h"

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

/////////////////////////////////////////////////////////////////////////////
// CEx19View

IMPLEMENT_DYNCREATE(CEx19View, CView)

BEGIN_MESSAGE_MAP(CEx19View, CView)
	//{{AFX_MSG_MAP(CEx19View)
		// 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()

/////////////////////////////////////////////////////////////////////////////
// CEx19View construction/destruction

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

}

CEx19View::~CEx19View()
{
}

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

	return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CEx19View drawing

void CEx19View::OnDraw(CDC* pDC)
{
	CEx19Doc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	// TODO: add draw code for native data here
	CRect rect;
	CBrush WhiteBrush;
	CBrush RedBrush;
	CBrush GreenBrush;
	CBrush BlueBrush;
	CBrush BlackBrush;
	CBrush YellowBrush;
	WhiteBrush.CreateSolidBrush(RGB(255,255,255));
	RedBrush.CreateSolidBrush(RGB(255,0,0));
	GreenBrush.CreateSolidBrush(RGB(0,255,0));
	BlueBrush.CreateSolidBrush(RGB(0,0,255));
	BlackBrush.CreateSolidBrush(RGB(0,0,0));
	YellowBrush.CreateSolidBrush(RGB(255,255,0));
	GetClientRect(&rect);

	if(pDoc->m_OperateType)
	{
		pDC->SelectObject(BlueBrush);//Blue
		pDC->Ellipse(50,50,100,100);
		pDC->SelectObject(WhiteBrush);
		pDC->Ellipse(54,54,96,96);	
		pDC->SelectObject(YellowBrush);//Yellow
		pDC->Ellipse(76,75,126,125);
		pDC->SelectObject(WhiteBrush);
		pDC->Ellipse(80,79,122,121);
		pDC->SelectObject(BlackBrush);//Black
		pDC->Ellipse(104,50,154,100);
		pDC->SelectObject(WhiteBrush);
		pDC->Ellipse(108,54,150,96);
		pDC->SelectObject(GreenBrush);//Green
		pDC->Ellipse(130,75,180,125);
		pDC->SelectObject(WhiteBrush);
		pDC->Ellipse(134,79,176,121);
		pDC->SelectObject(RedBrush);//Red
		pDC->Ellipse(158,50,208,100);
		pDC->SelectObject(WhiteBrush);
		pDC->Ellipse(162,54,204,96);

		pDC->TextOut(130,190,"支持奥运事业!");
	}
	else
	{
		pDC->SelectObject(WhiteBrush);
		pDC->FillRect(&rect,&WhiteBrush);
	}

	WhiteBrush.DeleteObject();
	RedBrush.DeleteObject();
	GreenBrush.DeleteObject();
	BlueBrush.DeleteObject();
	BlackBrush.DeleteObject();
	YellowBrush.DeleteObject();
}

/////////////////////////////////////////////////////////////////////////////
// CEx19View printing

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

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

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

/////////////////////////////////////////////////////////////////////////////
// CEx19View diagnostics

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

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

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

/////////////////////////////////////////////////////////////////////////////
// CEx19View message handlers

⌨️ 快捷键说明

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