📄 marsview.cpp
字号:
// MarsView.cpp : implementation of the CMarsView class
//
// 本程序是《疯狂的火星虫—面向对象状态机实践指南》的演示程序
//
// 版权所有 (C) 2004 王咏武
// http://www.contextfree.net/wangyw/
//
/////////////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "Mars.h"
#include "MarsDoc.h"
#include "MarsView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMarsView
IMPLEMENT_DYNCREATE(CMarsView, CView)
BEGIN_MESSAGE_MAP(CMarsView, CView)
//{{AFX_MSG_MAP(CMarsView)
ON_WM_SIZE()
ON_WM_TIMER()
ON_WM_CREATE()
ON_WM_DESTROY()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMarsView construction/destruction
CMarsView::CMarsView()
{
// TODO: add construction code here
}
CMarsView::~CMarsView()
{
}
BOOL CMarsView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CMarsView drawing
void CMarsView::OnDraw(CDC* pDC)
{
CMarsDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
pDoc->OnDraw(pDC);
}
/////////////////////////////////////////////////////////////////////////////
// CMarsView diagnostics
#ifdef _DEBUG
void CMarsView::AssertValid() const
{
CView::AssertValid();
}
void CMarsView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CMarsDoc* CMarsView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMarsDoc)));
return (CMarsDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CMarsView message handlers
void CMarsView::OnSize(UINT nType, int cx, int cy)
{
CView::OnSize(nType, cx, cy);
// TODO: Add your message handler code here
GetDocument()->SetWidth(cx);
GetDocument()->SetHeight(cy);
}
void CMarsView::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
GetDocument()->OnTimer();
CView::OnTimer(nIDEvent);
}
int CMarsView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CView::OnCreate(lpCreateStruct) == -1)
return -1;
// TODO: Add your specialized creation code here
SetTimer(1, 100, NULL);
return 0;
}
void CMarsView::OnDestroy()
{
CView::OnDestroy();
// TODO: Add your message handler code here
KillTimer(1);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -