public:
CBitmapm_bitmap;
// void Create(void);
voidCreate(UINT nBitmapID);
afx_msgvoid OnPaint();
afx_msgvoid OnTimer(UINT_PTR nIDEvent);
_Splash.cpp
BEGIN_MESSAGE_MAP(CWzdSplash, CWnd)
ON_WM_PAINT()
ON_WM_TIMER()
END_MESSAGE_MAP()
// CSplash 消息处理程序
void CSplash::Create(UINT nBitmapID)
{
m_bitmap.LoadBitmap(nBitmapID);
BITMAPbitmap;
m_bitmap.GetBitmap(&bitmap);
//CreateEx(0,AfxRegisterWndClass(0),"",WS_POPUP|WS_VISIBLE|WS_BORDER,0,0,bitmap.bmWidth,bitmap.bmHeight,NULL,0);
CreateEx(0,
AfxRegisterWndClass(0,AfxGetApp()->LoadStandardCursor(IDC_ARROW)),
NULL,WS_POPUP | WS_VISIBLE, 0, 0, bitmap.bmWidth, bitmap.bmHeight, NULL, NULL);
}
void CSplash::OnPaint()
{
//TODO: 在此处添加消息处理程序代码
//不为绘图消息调用 CWnd::OnPaint()
CPaintDCdc(this); // device context forpainting
BITMAPbitmap;
m_bitmap.GetBitmap(&bitmap);
CDCdcComp;
dcComp.CreateCompatibleDC(&dc);
dcComp.SelectObject(&m_bitmap);
//draw bitmap
dc.BitBlt(0,0, bitmap.bmWidth, bitmap.bmHeight, &dcComp, 0, 0, SRCCOPY);
}
void CSplash::OnTimer(UINT_PTR nIDEvent)
{
//TODO: 在此添加消息处理程序代码和/或调用默认值
//CWnd::OnTimer(nIDEvent);
DestroyWindow();//销毁初始画面窗口
}C_Dlg::OnInitDialog()
//创建启动窗口类的实例
CSplashwndSplash;
wndSplash.Create(IDB_SPLASH);
wndSplash.CenterWindow();
wndSplash.UpdateWindow();//sendWM_PAINT
Sleep(1500);//让线程休眠不是好办法
//SetTimer(1,1500, NULL);//不成功
wndSplash.DestroyWindow();//销毁初始画面窗口