Program startup Screen

Source: Internet
Author: User
Tags knowledge base

Contains the sample source code of this Article

I have seen many programs about the program startup screen in the VC knowledge base, and I think the program is "simple and easy to understand". I don't need too many skills, as long as the program is written, so I used another simple method to design the program startup screen and play the sound during the program startup, the key of this program is the sleep and playsound APIs and the strectblt function must remember to link winmm. the playsound function can be used only in Lib. The method is as follows:
Load bitmap in the csplashwindow: csplashwindow () construction function as the program startup Screen

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

Next is the specific description of the program.

Step 1.
Create three categories as program startup screen and main program

Class csplashwindow: Public cwnd // The splashwindow category {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 // The cmainwindow category for the main program {public: cmainwindow (); ~ Cmainwindow () ;}; class cmainwindowapp: Public cwinapp // used for program initialization cmainwindowapp category {public: cmainwindowapp ();~ Cmainwindowapp (); Virtual bool initinstance ();};

Step 2.
Use strectblt in void csplashwindow: onpaint () to copy the bitmap to the splashwindow as the startup screen.

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}

Step 3.
Initialize the startup Screen Settings in 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;

If you have any questions about this procedure, please feel free to contact our

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.