www.gusucode.com > 一款个性的Vc++软件启动界面源码源码程序 > 一款个性的Vc++软件启动界面源码/SplashWindow/SplashWindow/SplashWindow.cpp

    /*  Hello, If you have any Question?
	Download by http://www.srcfans.com
    Welcome E-mail me, My e-mail is r39710@giga.net.tw
    Thank you Bye
*/
#include<afxwin.h>
#include<mmsystem.h>
#include"SplashWindow.h"
#include"resource.h"

BEGIN_MESSAGE_MAP(CSplashWindow, CWnd)
  ON_WM_PAINT()
END_MESSAGE_MAP()

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);
}

CSplashWindow::~CSplashWindow()
{
}

void CSplashWindow::CreateSplash()
{
	//Create Splash Window
	CreateEx(0,
		     AfxRegisterWndClass(
			 0,
			 AfxGetApp()->LoadStandardCursor(IDC_UPARROW)),
			 "SplashWindow Sample",
			 WS_POPUP,
			 0,
			 0,
			 bmBitmap.bmWidth,  //Bitmap Width = Splash Window Width
			 bmBitmap.bmHeight, //Bitmap Height = Splash Window Height
			 NULL,
			 NULL,
			 NULL);
}

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
}

CMainWindow::CMainWindow()
{
	//Main Window
	CreateEx(0, NULL, "SplashWindow Sample", WS_OVERLAPPEDWINDOW,
		     rectDefault, NULL, NULL, 0);
}

CMainWindow::~CMainWindow()
{
}

CMainWindowApp::CMainWindowApp()
{
}

CMainWindowApp::~CMainWindowApp()
{
}

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 Second
	m_pSplashWindow->DestroyWindow(); //Destroy Splash Window
	delete m_pSplashWindow;
	
	m_pMainWnd = new CMainWindow;
	m_pMainWnd->ShowWindow(SW_SHOW);
	m_pMainWnd->UpdateWindow();
	return true;
}
CMainWindowApp MainWindowApp;