⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 1_1view.cpp

📁 又一个游戏编程基础的例子
💻 CPP
字号:
// 1_1View.cpp : implementation of the CMy1_1View class
//

#include "stdafx.h"
#include "1_1.h"

#include "1_1Doc.h"
#include "1_1View.h"

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

/////////////////////////////////////////////////////////////////////////////
// CMy1_1View

IMPLEMENT_DYNCREATE(CMy1_1View, CView)

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

/////////////////////////////////////////////////////////////////////////////
// CMy1_1View construction/destruction

CMy1_1View::CMy1_1View()
{
	// TODO: add construction code here
    ituxing=0;
}

CMy1_1View::~CMy1_1View()
{
}

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

	return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CMy1_1View drawing

void CMy1_1View::OnDraw(CDC* pDC)
{
	CMy1_1Doc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	// TODO: add draw code for native data here
	//清除当前圆形
	CBrush mybrush1;
	mybrush1.CreateSolidBrush(RGB(255,255,255));
	CRect myrect1(0,0,1024,768);
	pDC->FillRect(myrect1,&mybrush1);

	//用当前图形位置ituxing	
	//画圆
	pDC->Ellipse(30*ituxing,30*ituxing,30*ituxing+50,30*ituxing+50);
	
}

/////////////////////////////////////////////////////////////////////////////
// CMy1_1View printing

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

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

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

/////////////////////////////////////////////////////////////////////////////
// CMy1_1View diagnostics

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

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

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

/////////////////////////////////////////////////////////////////////////////
// CMy1_1View message handlers

void CMy1_1View::OnTimer(UINT nIDEvent) 
{
	// TODO: Add your message handler code here and/or call default
	//获取指针pdc
	CDC *pDC=GetDC();
	//调用OnDraw(pDC)重画
	OnDraw(pDC);
	//使ituxing循环
	ituxing=(ituxing+1)%10;

	CView::OnTimer(nIDEvent);
}

int CMy1_1View::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CView::OnCreate(lpCreateStruct) == -1)
		return -1;
	
	// TODO: Add your specialized creation code here
	//设置循环时间
	SetTimer(1, 750, NULL);
	return 0;
}

⌨️ 快捷键说明

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