drawcoinview.cpp

来自「这个是我们学校用的VC++教案」· C++ 代码 · 共 110 行

CPP
110
字号
// DrawCoinView.cpp : implementation of the CDrawCoinView class
//

#include "stdafx.h"
#include "DrawCoin.h"

#include "DrawCoinDoc.h"
#include "DrawCoinView.h"

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

/////////////////////////////////////////////////////////////////////////////
// CDrawCoinView

IMPLEMENT_DYNCREATE(CDrawCoinView, CView)

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

/////////////////////////////////////////////////////////////////////////////
// CDrawCoinView construction/destruction

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

}

CDrawCoinView::~CDrawCoinView()
{
}

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

	return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CDrawCoinView drawing

void CDrawCoinView::OnDraw(CDC* pDC)
{
	CDrawCoinDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	// TODO: add draw code for native data here
	for(int i=0;i<pDoc->m_nCoins;i++)
	{
		int y=200-10*i;
		pDC->Ellipse(200,y,300,y-30);  // 用两个偏移的椭圆表示一枚硬币
		pDC->Ellipse(200,y-10,300,y-35);
	}
}

/////////////////////////////////////////////////////////////////////////////
// CDrawCoinView printing

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

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

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

/////////////////////////////////////////////////////////////////////////////
// CDrawCoinView diagnostics

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

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

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

/////////////////////////////////////////////////////////////////////////////
// CDrawCoinView message handlers

⌨️ 快捷键说明

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