c++游戏设计一:清明上河图的播放

来源:互联网 发布:注销淘宝账号在申请 编辑:程序博客网 时间:2024/05/08 19:42

一个自动播放清明上河图的程序。MFC空项目自己写。

#include <afxwin.h>class CMyWnd :public CFrameWnd{private:CDC *m_pmdc;CBitmap *m_pbitmap;int cX;public:CMyWnd(){Create(NULL,"First App");CClientDC dc(this);m_pmdc=new CDC;m_pbitmap=new CBitmap;MoveWindow(20,20,920,720);m_pbitmap->m_hObject=(HBITMAP)::LoadImage(NULL,"../image/1.bmp",              IMAGE_BITMAP, 0,0,LR_LOADFROMFILE);m_pmdc->CreateCompatibleDC(&dc);m_pmdc->SelectObject(m_pbitmap);SetTimer(1,10,NULL);cX=0;}~CMyWnd(){delete m_pbitmap;delete m_pmdc;}DECLARE_MESSAGE_MAP()afx_msg void OnPaint();afx_msg void OnTimer(UINT_PTR nIDEvent);};class CMyApp:public CWinApp{public:BOOL InitInstance();};BOOL CMyApp::InitInstance(){CMyWnd *pf=new CMyWnd;pf->ShowWindow(m_nCmdShow);this->m_pMainWnd=pf;return TRUE;}CMyApp FirstApp;BEGIN_MESSAGE_MAP(CMyWnd, CFrameWnd)ON_WM_PAINT()ON_WM_TIMER()END_MESSAGE_MAP()void CMyWnd::OnPaint(){CPaintDC dc(this); // device context for painting// TODO: 在此处添加消息处理程序代码// 不为绘图消息调用 CFrameWnd::OnPaint()dc.BitBlt(0,0,920,720,m_pmdc,cX,0,SRCCOPY);if(cX==19000)KillTimer(1);}void CMyWnd::OnTimer(UINT_PTR nIDEvent){// TODO: 在此添加消息处理程序代码和/或调用默认值cX++;Invalidate(0);CFrameWnd::OnTimer(nIDEvent);}



0 0
原创粉丝点击