Program launch screen

xiaoxiao2021-03-06  66

This document is described in the VC Knowledge Source Code On the VC Knowledge Base. I feel that the program is "simple and easy". It doesn't need too much skill. As long as the program is written, it is good, so I In another simple way, the program start screen will play the sound at the same time when the program is started, the key to this program is that the two API functions of Sleep and Plays and STRECTBLT must remember to connect WinMM.Lib to use the Plays Support, specifically The method is as follows: Load the bitmap in the csplashwindow :: csplashwindow () constructive function as a program start 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, the specific description of this program is step. Establish three categories, respectively, as a program start screen and main program

Class CsplashWindow: SplashWindow category for program startup screen

{

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 // Class for the main program

{

PUBLIC:

CMAINWINDOW ();

~ Cmainwindow ();

}

Class CMainWindowapp: public cwinapp // Used for program initialization CMAINWINDOWAPP categories

{

PUBLIC:

CMainWindowApp ();

~ Cmainwindowapp ();

Virtual Bool InitInstance ();

}

Step 2. In Void CsplashWindow :: OnPaint () Use the STRECTBLT copy bitmap to SplashWindow as a startup screen

Void csplashwindow :: onpaint ()

{

CPAINTDC DC (this);

MEMDC.CREATECOMPALED (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. In the void cmainwindowapp :: initInstance (), the setting of the startup screen is initialized.

Bool cmainwindowapp :: initInstance ()

{

CSPLASHWINDOW * m_psplashwindow = new csplashwindow;

m_psplashwindow-> createSplash ();

m_psplashwindow-> centerWindow (); m_psplashwindow-> showwindow;

m_psplashwindow-> UpdateWindow ();

Sleep (3000); // delay 3 seconds

m_psplashwindow-> destroyWindow (); // destroy window

Delete m_psplashwindow;

m_pmainwnd = new cmainwindow;

m_pmainwnd-> showwindow;

m_pmainwnd-> UpdateWindow ();

Return True;

}

CMainwindowapp mainwindowapp;

If you have any questions about this procedure, you are welcome to tell R39710@giga.net.tw

转载请注明原文地址:https://www.9cbs.com/read-90524.html

New Post(0)