VS启动画面
2015-06-02 21:10
155 查看
1、添加图片资源到工程中,如IDB_BITMAP_LOGIN
2、添加自定义启动画面类CWzdSplash
(1)CWzdSplash.h文件内容:
#pragma once
// CWzdSplash
class CWzdSplash : public CWnd
{
DECLARE_DYNAMIC(CWzdSplash)
public:
CWzdSplash();
virtual ~CWzdSplash();
protected:
DECLARE_MESSAGE_MAP()
public:
CBitmap m_bitmap;
void Create(UINT nBitmapID, CWnd* pParentWnd = NULL);
afx_msg void OnPaint();
afx_msg void OnTimer(UINT_PTR nIDEvent);
};
(2)CWzdSplash.cpp文件内容:
#include "stdafx.h"
#include "CWzdSplash.h"
// CwzdSplash
IMPLEMENT_DYNAMIC(CWzdSplash, CWnd)
CWzdSplash::CWzdSplash()
{
}
CWzdSplash::~CWzdSplash()
{
}
BEGIN_MESSAGE_MAP(CWzdSplash, CWnd)
ON_WM_PAINT()
ON_WM_TIMER()
END_MESSAGE_MAP()
// CWzdSplash 消息处理程序
void CWzdSplash::Create(UINT nBitmapID, CWnd* pParentWnd)
{
m_bitmap.LoadBitmap(nBitmapID);
BITMAP bitmap;
m_bitmap.GetBitmap(&bitmap);
//CreateEx(0,AfxRegisterWndClass(0),"",WS_POPUP|WS_VISIBLE|WS_BORDER,0,0,bitmap.bmWidth,bitmap.bmHeight,NULL,0);
HWND hParentWnd = NULL;
if (NULL != pParentWnd)
{
hParentWnd = pParentWnd->m_hWnd;
}
CreateEx(0,
AfxRegisterWndClass(0, AfxGetApp()->LoadStandardCursor(IDC_ARROW)),
NULL, WS_POPUP | WS_VISIBLE, 0, 0, bitmap.bmWidth, bitmap.bmHeight, hParentWnd, NULL);
}
void CWzdSplash::OnPaint()
{
// TODO: 在此处添加消息处理程序代码
// 不为绘图消息调用 CWnd::OnPaint()
CPaintDC dc(this); // device context forpainting
BITMAP bitmap;
m_bitmap.GetBitmap(&bitmap);
CDC dcComp;
dcComp.CreateCompatibleDC(&dc);
dcComp.SelectObject(&m_bitmap);
// draw bitmap
dc.BitBlt(0,0,bitmap.bmWidth,bitmap.bmHeight,&dcComp,0,0,SRCCOPY);
}
void CWzdSplash::OnTimer(UINT_PTR nIDEvent)
{
// TODO: 在此添加消息处理程序代码和/或调用默认值
//CWnd::OnTimer(nIDEvent);
DestroyWindow(); //销毁初始画面窗口
}
3、在APP类的InitInstance函数中添加
/*启动画面*/
CWzdSplash wndSplash; //创建启动窗口类的实例
wndSplash.Create(IDB_BITMAP_LOGIN, pMainFrame);
wndSplash.CenterWindow();
wndSplash.UpdateWindow();
2、添加自定义启动画面类CWzdSplash
(1)CWzdSplash.h文件内容:
#pragma once
// CWzdSplash
class CWzdSplash : public CWnd
{
DECLARE_DYNAMIC(CWzdSplash)
public:
CWzdSplash();
virtual ~CWzdSplash();
protected:
DECLARE_MESSAGE_MAP()
public:
CBitmap m_bitmap;
void Create(UINT nBitmapID, CWnd* pParentWnd = NULL);
afx_msg void OnPaint();
afx_msg void OnTimer(UINT_PTR nIDEvent);
};
(2)CWzdSplash.cpp文件内容:
#include "stdafx.h"
#include "CWzdSplash.h"
// CwzdSplash
IMPLEMENT_DYNAMIC(CWzdSplash, CWnd)
CWzdSplash::CWzdSplash()
{
}
CWzdSplash::~CWzdSplash()
{
}
BEGIN_MESSAGE_MAP(CWzdSplash, CWnd)
ON_WM_PAINT()
ON_WM_TIMER()
END_MESSAGE_MAP()
// CWzdSplash 消息处理程序
void CWzdSplash::Create(UINT nBitmapID, CWnd* pParentWnd)
{
m_bitmap.LoadBitmap(nBitmapID);
BITMAP bitmap;
m_bitmap.GetBitmap(&bitmap);
//CreateEx(0,AfxRegisterWndClass(0),"",WS_POPUP|WS_VISIBLE|WS_BORDER,0,0,bitmap.bmWidth,bitmap.bmHeight,NULL,0);
HWND hParentWnd = NULL;
if (NULL != pParentWnd)
{
hParentWnd = pParentWnd->m_hWnd;
}
CreateEx(0,
AfxRegisterWndClass(0, AfxGetApp()->LoadStandardCursor(IDC_ARROW)),
NULL, WS_POPUP | WS_VISIBLE, 0, 0, bitmap.bmWidth, bitmap.bmHeight, hParentWnd, NULL);
}
void CWzdSplash::OnPaint()
{
// TODO: 在此处添加消息处理程序代码
// 不为绘图消息调用 CWnd::OnPaint()
CPaintDC dc(this); // device context forpainting
BITMAP bitmap;
m_bitmap.GetBitmap(&bitmap);
CDC dcComp;
dcComp.CreateCompatibleDC(&dc);
dcComp.SelectObject(&m_bitmap);
// draw bitmap
dc.BitBlt(0,0,bitmap.bmWidth,bitmap.bmHeight,&dcComp,0,0,SRCCOPY);
}
void CWzdSplash::OnTimer(UINT_PTR nIDEvent)
{
// TODO: 在此添加消息处理程序代码和/或调用默认值
//CWnd::OnTimer(nIDEvent);
DestroyWindow(); //销毁初始画面窗口
}
3、在APP类的InitInstance函数中添加
/*启动画面*/
CWzdSplash wndSplash; //创建启动窗口类的实例
wndSplash.Create(IDB_BITMAP_LOGIN, pMainFrame);
wndSplash.CenterWindow();
wndSplash.UpdateWindow();
相关文章推荐
- 软件工程 课程改进意见
- 1124
- 暴力/DP Codeforces Beta Round #22 (Div. 2 Only) B. Bargaining Table
- 网络编程
- 移动互联网第一步
- 第二次冲刺 站立会议9
- 021_01NotificationManager应用
- 优化产品使用体验记录一
- ios 安卓锁屏
- cocos2d-x 3.0 触摸机制的使用
- JavaScript开发人员需了解的工具内容
- POJ 1287 Networking (最小生成树)
- .net mvc4 从客户端中检测到有潜在危险的 Request.Form 值
- Swiper使用说明
- opencv源码研究: icvGetHaarTrainingDataFromBG和icvGetHaarTrainingDataFromVec的区别
- 理解JS原型以及实现继承
- Linux内核编程接口函数
- 由几道JS笔试题引发的知识点探究
- 8.18在类模板外定义成员函数,实现3个数求和
- VMware中Ubuntu 14.04出现Unknown Display问题解决