设为首页 加入收藏

TOP

怎样实现动画背景旗帜
2014-11-23 20:10:07 来源: 作者: 【 】 浏览:9
Tags:怎样 实现 动画 背景 旗帜

以下代码是关于用类CmdiMainClient来显示动画背景旗帜的一个例子。原理是很简单的,我们只需要一系列连续的位图,并且让它连续显示。在这个例子中你可以用鼠标的右键来开始/停止这个动画,如果点左键的话,就可以显示一个子窗口,来保持动画是继续。为了你的方便,你可以把代码直接从浏览器中拷贝下去,并且插到你的代码中就行了。以下是代码:

#include "stdafx.h"

#include "banner.h"

#include "mainfrm.h"

#include "resource.h"

#ifdef _DEBUG

#undef THIS_FILE

static char BASED_CODE THIS_FILE[] = __FILE__;

#endif

/////////////////////////////////////////////////////////////////////////////

// CMdiMainClient

CMdiMainClient::CMdiMainClient()

: m_sizeClient(0, 0)

{

VERIFY (m_bmpBackGround.LoadBitmap(IDB_BCKGRD));

ASSERT (m_bmpBackGround.GetSafeHandle());

VERIFY (m_bmpBackGround2.LoadBitmap(IDB_BITMAP0));

ASSERT (m_bmpBackGround2.GetSafeHandle());

BmpLoaded = 1;

StopRotation = FALSE;

}

CMdiMainClient::~CMdiMainClient()

{

if(m_bmpBackGround.GetSafeHandle())

m_bmpBackGround.DeleteObject();

if(m_bmpBackGround2.GetSafeHandle())

m_bmpBackGround2.DeleteObject();

}

BEGIN_MESSAGE_MAP(CMdiMainClient, CWnd)

//{{AFX_MSG_MAP(CMdiMainClient)

// NOTE - the ClassWizard will add and remove mapping macros here.

ON_WM_TIMER()

ON_WM_ERASEBKGND()

ON_WM_RBUTTONDOWN()

ON_WM_LBUTTONDOWN()

ON_WM_SIZE()

//}}AFX_MSG_MAP

END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////

// CMdiMainClient message handlers

BOOL CMdiMainClient::OnEraseBkgnd(CDC* pDC)

{

// Erase only the area needed

CRect rect;

GetClientRect(&rect) ;

SetTimer(0,300,NULL);

// Place the bitmap

BITMAP bm ;

CDC dcMem ;

&nb

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇在MFC程序中显示JPG/GIF图像 下一篇自己动手制作一款简洁实用的图片..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: