📄 runmanview.cpp
字号:
// RunManView.cpp : implementation of the CRunManView class
//
#include "stdafx.h"
#include "RunMan.h"
#include "RunManDoc.h"
#include "RunManView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CRunManView
IMPLEMENT_DYNCREATE(CRunManView, CView)
BEGIN_MESSAGE_MAP(CRunManView, CView)
//{{AFX_MSG_MAP(CRunManView)
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()
/////////////////////////////////////////////////////////////////////////////
// CRunManView construction/destruction
CRunManView::CRunManView()
{
// TODO: add construction code here
i=2;
nCenterX=0;
nRUN=1;
nCenterY=150;
nRUN2=1;
}
CRunManView::~CRunManView()
{
}
BOOL CRunManView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CRunManView drawing
void CRunManView::OnDraw(CDC* pDC)
{
CRunManDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
SetTimer(1,100,NULL);
CRect Rect;
GetClientRect(&Rect);
CDC MemDC;
MemDC.CreateCompatibleDC(pDC);
CBrush *OldBrush,Brush(RGB(192,192,192));
OldBrush=pDC->SelectObject(&Brush);
pDC->Rectangle(0,0,Rect.right,Rect.bottom);
CBitmap Bitmap;
Bitmap.LoadBitmap(i);
CBitmap *pOldBitmap=MemDC.SelectObject(&Bitmap);
BITMAP bm;
Bitmap.GetObject(sizeof(BITMAP),&bm);
pDC->BitBlt(nCenterX,nCenterY,bm.bmWidth,bm.bmHeight,&MemDC,0,0,SRCCOPY);
MemDC.SelectObject(pOldBitmap);
}
/////////////////////////////////////////////////////////////////////////////
// CRunManView printing
BOOL CRunManView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CRunManView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CRunManView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CRunManView diagnostics
#ifdef _DEBUG
void CRunManView::AssertValid() const
{
CView::AssertValid();
}
void CRunManView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CRunManDoc* CRunManView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CRunManDoc)));
return (CRunManDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CRunManView message handlers
void CRunManView::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
CRect Rect;
GetClientRect(&Rect);
{if(nRUN2)
{if(nCenterY<(Rect.bottom-75))//判断是否到达了屏幕的最下边;
nCenterY+=10;//如果是到达了最下边,往回跳;
else
nRUN2--;
}
else
{if(nCenterY>1)
nCenterY-=10;
else
nRUN2++;}}
{if (nRUN)
{if(nCenterX<=(Rect.right-45))//判断是否到达了屏幕的最下边
{if(i<=12)
{i++;
nCenterX+=10;
}
else
{i=2;
nCenterX+=10;
}}
else
{i=14;
nRUN--;}}
else
{if(nCenterX>1)
{ if(i<25)
{i++;
nCenterX-=10;}//往回跳
else
{i=14;
nCenterX-=10;}
}
else
nRUN++;}}
CWnd::Invalidate(NULL);
CView::OnTimer(nIDEvent);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -