求像skype那样一启动有个闪屏,能自动消失的完整代码

lpszDefExt 2009-03-25 04:31:36
主要是能实现exe启动时间稍微长点,有个画面友好显示的功能,
做个闪屏应该就可以了,我做了个总是不能正常表示主画面,很郁闷,求这方面代码。
...全文
80 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
lpszDefExt 2009-03-30
  • 打赏
  • 举报
回复
thank you to linaren,OK
linaren 2009-03-25
  • 打赏
  • 举报
回复
CSplashWnd::EnableSplashScreen(1);
CSplashWnd::ShowSplashScreen(/* CWnd * */pParentWnd);
linaren 2009-03-25
  • 打赏
  • 举报
回复

#include "stdafx.h"
#include "Splash.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif
// スプラッシュ スクリーン クラス
BOOL CSplashWnd::c_bShowSplashWnd;
CSplashWnd *CSplashWnd::c_pSplashWnd;
CSplashWnd::CSplashWnd()
{
}
CSplashWnd::~CSplashWnd()
{
//
ASSERT(c_pSplashWnd == this);
c_pSplashWnd = NULL;
}
BEGIN_MESSAGE_MAP(CSplashWnd, CWnd)
//{{AFX_MSG_MAP(CSplashWnd)
ON_WM_CREATE()
ON_WM_PAINT()
ON_WM_TIMER()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
void CSplashWnd::EnableSplashScreen(BOOL bEnable /*= TRUE*/ )
{
c_bShowSplashWnd = bEnable;
}
void CSplashWnd::ShowSplashScreen(CWnd * pParentWnd /*= NULL*/ )
{
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) {
return FALSE; //
}
return FALSE; //
}
BOOL CSplashWnd::Create(CWnd * pParentWnd /*= NULL*/ )
{
HRSRC hrSrc =::FindResource(NULL, MAKEINTRESOURCE(IDB_SPLASH), RT_BITMAP);
LPVOID lpvResource = (LPVOID)::LoadResource(NULL, hrSrc); //
m_Dib.AttachMemory(lpvResource); // no need for lock
CSize size = m_Dib.GetDimensions();
return CreateEx(0, AfxRegisterWndClass(0, AfxGetApp()->LoadStandardCursor(IDC_ARROW)), NULL,
WS_POPUP | WS_VISIBLE, 0, 0, size.cx, size.cy, pParentWnd->GetSafeHwnd(), NULL);
}
void CSplashWnd::HideSplashScreen()
{
//
DestroyWindow();
AfxGetMainWnd()->UpdateWindow();
}
void CSplashWnd::PostNcDestroy()
{
//
delete this;
}
int CSplashWnd::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CWnd::OnCreate(lpCreateStruct) == -1)
return -1;
//
CenterWindow();
//
SetTimer(1, 750 * 3, NULL);
return 0;
}
void CSplashWnd::OnPaint()
{
CPaintDC dc(this);
CSize size = m_Dib.GetDimensions();
m_Dib.Draw(&dc, CPoint(0, 0), size);
}
void CSplashWnd::OnTimer(UINT nIDEvent)
{
//
HideSplashScreen();
}
linaren 2009-03-25
  • 打赏
  • 举报
回复
闪屏单独类:头文件

#include "Mask.h"
#include "ComConvBmp.h"
class CSplashWnd : public CWnd
{

protected:
CSplashWnd();
//
public:
//CBitmap m_bitmap;
CDib m_Dib;
//
public:
static void EnableSplashScreen(BOOL bEnable = TRUE);
static void ShowSplashScreen(CWnd* pParentWnd = NULL);
static BOOL PreTranslateAppMessage(MSG* pMsg);
//
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CSplashWnd)
//}}AFX_VIRTUAL
//
public:
~CSplashWnd();
virtual void PostNcDestroy();
protected:
BOOL Create(CWnd* pParentWnd = NULL);
void HideSplashScreen();
static BOOL c_bShowSplashWnd;
static CSplashWnd* c_pSplashWnd;
//
protected:
//{{AFX_MSG(CSplashWnd)
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnPaint();
afx_msg void OnTimer(UINT nIDEvent);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
悔说话的哑巴 2009-03-25
  • 打赏
  • 举报
回复
帮顶

7,540

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 VC.NET
社区管理员
  • VC.NET社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧