test1view.cpp

来自「有效地使用蒙特卡洛方法研究中子屏蔽给出屏蔽体性质」· C++ 代码 · 共 142 行

CPP
142
字号
// test1View.cpp : implementation of the CTest1View class
//

#include "stdafx.h"
#include "test1.h"
#include "Beetle.h"
#include "Ant.h"
#include "test1Doc.h"
#include "test1View.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
Ant an1,an2;
Beetle be;
/////////////////////////////////////////////////////////////////////////////
// CTest1View

IMPLEMENT_DYNCREATE(CTest1View, CView)

BEGIN_MESSAGE_MAP(CTest1View, CView)
	//{{AFX_MSG_MAP(CTest1View)
	ON_COMMAND(ID_RUN, OnRun)
	ON_WM_TIMER()
	//}}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()

/////////////////////////////////////////////////////////////////////////////
// CTest1View construction/destruction

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

}

CTest1View::~CTest1View()
{
}

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

	return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CTest1View drawing

void CTest1View::OnDraw(CDC* pDC)
{
	CTest1Doc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	// TODO: add draw code for native data here
}

/////////////////////////////////////////////////////////////////////////////
// CTest1View printing

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

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

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

/////////////////////////////////////////////////////////////////////////////
// CTest1View diagnostics

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

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

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

/////////////////////////////////////////////////////////////////////////////
// CTest1View message handlers

void CTest1View::OnRun() 
{
	// TODO: Add your command handler code here
	SetTimer(1,20,NULL);
	SetTimer(2,20,NULL);
	SetTimer(3,20,NULL);
}

void CTest1View::OnTimer(UINT nIDEvent) 
{
	CClientDC DC(this);
	if(nIDEvent==1)
	{
		an1.AntMove (10,10);
		DC.Ellipse(an1.PosX,an1.PosY,an1.PosX+2,an1.PosY+2);
		if(an1.PosX>500)
			KillTimer(1);
	}
	if(nIDEvent==2)
	{
		an2.AntMove(11,11);
		DC.Ellipse(an2.PosX,an2.PosY,an2.PosX+5,an2.PosY+5);
		if(an2.PosX>500)
			KillTimer(2);
	}
	if(nIDEvent==3)
	{
		be.BeetleMove ();
		DC.Ellipse(be.PosX,be.PosY,be.PosX+5,be.PosY+5);
		if(be.PosX>500)
			KillTimer(3);
	}
	CView::OnTimer(nIDEvent);
}

⌨️ 快捷键说明

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