当前位置: 首页 > 图文教程 > 开发语言 > VC++ > 简易方法淡入淡出启动画面
| 简易方法淡入淡出启动画面 下载源代码 #undef WINVER //取消原有版本定义,重新定义版本#define WINVER 0x5000 //为了使AnimateWindow函数可用#include <afxwin.h>然后在相关文件分别加入OnCreate,OnClose,OnEraseBkgnd和OnTimer消息函数。记得在相关构析函数内加入 : SetTimer(1, 3000, NULL); //设定定时器1,定时3秒OnCreate消息函数里添加淡入窗口或者背景位图代码 BOOL CSplashWnd::OnCreate(LPCREATESTRUCT lpcs){ CenterWindow(); //窗口位于屏幕中心 AnimateWindow(GetSafeHwnd(), 500, AW_BLEND); //淡入图片0.5秒 return true;}OnClose消息函数是添加淡出窗口或背景位图代码:void CSplashWnd::OnClose(){ AnimateWindow(GetSafeHwnd(), 500, AW_BLEND | AW_HIDE); //淡出图片0.5秒 CWnd::OnClose();} OnEraseBkgnd消息函数是添加背景位图:BOOL CSplashWnd::OnEraseBkgnd(CDC *pDC){ DDB mSplashBitmap; mSplashBitmap.DisplayDDB(pDC, IDB_SPLASH); //显示位图资源IDB_SPLASH return true;} OnTimer消息函数是添加定时关闭代码:void CSplashWnd::OnTimer(UINT nIDEvent){ KillTimer(1); //关闭定时器1 PostMessage(WM_CLOSE, 0, 0); //发送关闭窗口信息} 是不是很简单,我看有些关于位图和窗口的淡入淡出很复杂,我刚学VC不久,看不懂。只好想出这简便的办法。有什么建议和意见欢迎大家指出! |