CSplashWindow::CSplashWindow()
{
m_Bitmap.LoadBitmap(MAKEINTRESOURCE(IDB_SPLASHWINDOW)); //Load Bitmap
m_Bitmap.GetBitmap(&bmBitmap); //Get Bitmap Info
/*Show Splash Window and Play SplashWindow.wav*/
::PlaySound("SplashWindow.wav", NULL, SND_ASYNC | SND_FILENAME);
}接着是此程序的具体描述
步骤一.
建立三个类别,分别作为程序启动画面与主程序
class CSplashWindow : public CWnd //用于程序启动画面的SplashWindow类别
{
private:
CDC MemDC;
BITMAP bmBitmap;
CBitmap m_Bitmap;
CBitmap *Old_Bitmap;
public:
CSplashWindow();
~CSplashWindow();
void CreateSplash();
afx_msg void OnPaint();
DECLARE_MESSAGE_MAP()
};
class CMainWindow : public CFrameWnd //用于主程序的CMainWindow类别
{
public:
CMainWindow();
~CMainWindow();
};
class CMainWindowApp : public CWinApp //用于程序初始化CMainWindowApp类别
{
public:
CMainWindowApp();
~CMainWindowApp();
virtual BOOL InitInstance();
}; 步骤二.
在void CSplashWindow::OnPaint()当中使用StrectBlt复制位图到SplashWindow以当作启动画面
void CSplashWindow::OnPaint()
{
CPaintDC dc(this);
MemDC.CreateCompatibleDC(NULL); //Create Memory DC
Old_Bitmap = MemDC.SelectObject(&m_Bitmap); //Select DC
dc.StretchBlt(0,
0,
bmBitmap.bmWidth,
bmBitmap.bmHeight,
&MemDC,
0,
0,
bmBitmap.bmWidth,
bmBitmap.bmHeight,
SRCCOPY);
MemDC.SelectObject(Old_Bitmap); //Select Bitmap
} 步骤三.
在void CMainWindowApp::InitInstance()当中初始化启动画面的相关设定
BOOL CMainWindowApp::InitInstance() { CSplashWindow *m_pSplashWindow = new CSplashWindow; m_pSplashWindow->CreateSplash(); m_pSplashWindow->CenterWindow(); m_pSplashWindow->ShowWindow(SW_SHOW); m_pSplashWindow->UpdateWindow(); Sleep(3000); //Delay 3 Seconds m_pSplashWindow->DestroyWindow(); //Destroy Window delete m_pSplashWindow; m_pMainWnd = new CMainWindow; m_pMainWnd->ShowWindow(SW_SHOW); m_pMainWnd->UpdateWindow(); return true; } CMainWindowApp MainWindowApp;如果您对此程序有任何问题欢迎来信指教[email protected]
本文地址:http://com.8s8s.com/it/it25310.htm