封装类之CSplashWnd(应用程序的启动画面)
来源:互联网 发布:apache ab get参数 编辑:程序博客网 时间:2024/05/22 12:36
1XX.h文件
class CSplashWnd : public CWnd{ DECLARE_DYNAMIC(CSplashWnd)public: CSplashWnd(); virtual ~CSplashWnd();protected: virtual void PostNcDestroy(); afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); afx_msg void OnTimer(UINT_PTR nIDEvent); afx_msg void OnPaint(); BOOL Create(CWnd* pParentWnd=NULL); void HideSplashScreen(void); DECLARE_MESSAGE_MAP()protected: CBitmap m_bitmap; static CSplashWnd* c_pSplashWnd; static BOOL c_bShowSplashWnd;public: static void EnableSplashScreen(BOOL bEnable=TRUE); static void ShowSplashScreen(CWnd* pParentWnd=NULL); static BOOL PreTranslateAppMessage(MSG* pMsg);};
2XX.cpp文件
// SplashWnd.cpp : 实现文件//#include "stdafx.h"#include "SplashScreen.h"#include "SplashWnd.h"#include "resource.h"// CSplashWndCSplashWnd* CSplashWnd::c_pSplashWnd;BOOL CSplashWnd::c_bShowSplashWnd;IMPLEMENT_DYNAMIC(CSplashWnd, CWnd)CSplashWnd::CSplashWnd(){}CSplashWnd::~CSplashWnd(){ ASSERT(c_pSplashWnd == this); c_pSplashWnd = NULL;}BEGIN_MESSAGE_MAP(CSplashWnd, CWnd) ON_WM_CREATE() ON_WM_TIMER() ON_WM_PAINT()END_MESSAGE_MAP()// CSplashWnd 消息处理程序void CSplashWnd::EnableSplashScreen(BOOL bEnable){ c_bShowSplashWnd = bEnable;}void CSplashWnd::ShowSplashScreen(CWnd* pParentWnd){ if ( !c_bShowSplashWnd || c_pSplashWnd != NULL ) { return; } c_pSplashWnd = new CSplashWnd; if ( !c_pSplashWnd->Create(pParentWnd) ) { delete c_pSplashWnd; } else { c_pSplashWnd->UpdateWindow(); }}BOOL CSplashWnd::PreTranslateAppMessage(MSG* pMsg){ if ( c_pSplashWnd == NULL ) { return FALSE; } if ( pMsg->message == WM_KEYDOWN || pMsg->message == WM_SYSKEYDOWN || pMsg->message == WM_LBUTTONDOWN || pMsg->message == WM_RBUTTONDOWN || pMsg->message == WM_MBUTTONDOWN || pMsg->message == WM_NCLBUTTONDOWN || pMsg->message == WM_NCRBUTTONDOWN || pMsg->message == WM_NCMBUTTONDOWN) { c_pSplashWnd->HideSplashScreen(); return TRUE; } return FALSE;}void CSplashWnd::PostNcDestroy(){ delete this;}int CSplashWnd::OnCreate(LPCREATESTRUCT lpCreateStruct){ if ( CWnd::OnCreate(lpCreateStruct) == -1 ) { return -1; } CenterWindow(); SetTimer(1, 3000, NULL); return 0;}void CSplashWnd::OnTimer(UINT_PTR nIDEvent){ if ( nIDEvent == 1 ) { HideSplashScreen(); }}void CSplashWnd::OnPaint(){ CPaintDC dc(this); CDC dcImg; if ( !dcImg.CreateCompatibleDC(&dc) ) { return; } BITMAP bm; m_bitmap.GetBitmap(&bm); CBitmap* pOldBit = dcImg.SelectObject(&m_bitmap); dc.BitBlt(0, 0, bm.bmWidth, bm.bmHeight, &dcImg, 0, 0, SRCCOPY); dcImg.SelectObject(pOldBit);}BOOL CSplashWnd::Create(CWnd* pParentWnd){ if ( !m_bitmap.LoadBitmap(IDB_SPLASH)) { return FALSE; } BITMAP bm; m_bitmap.GetBitmap(&bm); return CreateEx(0, AfxRegisterWndClass(0, AfxGetApp()->LoadStandardCursor(IDC_ARROW)), NULL, WS_POPUP | WS_VISIBLE, 0, 0, bm.bmWidth, bm.bmHeight, pParentWnd->GetSafeHwnd(), NULL);}void CSplashWnd::HideSplashScreen(){ DestroyWindow(); AfxGetMainWnd()->UpdateWindow();}
0 0
- 封装类之CSplashWnd(应用程序的启动画面)
- 基于对话框的应用程序添加启动画面
- 基于对话框的应用程序添加启动画面
- 为你的应用程序添加启动画面
- 在你的应用程序添加启动画面
- wince的CSplashWnd
- 创建Cordova应用程序启动画面
- IOS编程教程(八):在你的应用程序添加启动画面
- 让基于对话框的应用程序有启动画面
- vc中为应用程序制作启动画面的简单方法
- vc基于对话框的应用程序添加启动画面
- 为基于对话框的应用程序设置启动画面
- Android之高仿微信“启动画面”(一)
- Qt的启动画面
- 用VC制作应用程序启动画面
- 用visualc++制作应用程序启动画面
- 用VC制作应用程序启动画面
- 利用Visual C++制作应用程序启动画面
- android 学习笔记 数据存储到文件中
- 鼓励自己成为一名合格程序设计师
- UI_NavigationController
- STL vector的使用(三)遍历
- json
- 封装类之CSplashWnd(应用程序的启动画面)
- 基于栈的一些操作
- codeforces 498C C. Array and Operations(最大流+数论)
- 在运行期通过反射了解JVM内部机制
- MFC 车牌识别 小学期作业 part4
- Linux学习记录(5)Vi编辑器基本使用
- 快速排序
- 天声人語 20150825
- 直接topbar奔溃,出现 at java.lang.reflect.Constructor.constructNative(Native Method)