当前位置: 首页 > 图文教程 > 开发语言 > VC++ > VC++工程中加入 SplashScreen 原理释解
| VC++工程中加入 SplashScreen 原理释解 下载源代码 //类的声明 class CSplashWnd : public CWnd{ CSplashWnd(); ~CSplashWnd(); virtual void PostNcDestroy(); static void EnableSplashScreen(BOOL bEnable = TRUE); static void ShowSplashScreen(CWnd* pParentWnd = NULL); static BOOL PreTranslateAppMessage(MSG* pMsg); BOOL Create(CWnd* pParentWnd = NULL); void HideSplashScreen(); afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); afx_msg void OnPaint(); afx_msg void OnTimer(UINT nIDEvent); CBitmap m_bitmap; //SplashScreen窗口显示用的位图对象 static BOOL c_bShowSplashWnd; //是否要显示SplashScreen的标志量 static CSplashWnd* c_pSplashWnd;}; //是否使用SplashScreen void CSplashWnd::EnableSplashScreen(BOOL bEnable){ c_bShowSplashWnd = bEnable;} //创建CsplashWnd对象,并调用Create()创建窗口void CSplashWnd::ShowSplashScreen(CWnd* pParentWnd){ //如果不要显示SplashScreen或SplashWnd对象已经被创建则返回 if (!c_bShowSplashWnd || c_pSplashWnd != NULL) return; c_pSplashWnd = new CSplashWnd; if (!c_pSplashWnd->Create(pParentWnd)) delete c_pSplashWnd; else c_pSplashWnd->UpdateWindow();} //装入SplashScreen欲显示位图,通过CreateEx()激发OnCreate()完成窗口创建与设置 BOOL CSplashWnd::Create(CWnd* pParentWnd){ if (!m_bitmap.LoadBitmap(IDB_SPLASH)) return FALSE; BITMAP bm; m_bitmap.GetBitmap(&bm); return CreateEx(0, |