Create an application with a master frame structure with the MFC Application Wizard to make it a startup screen (here you will experience), and make a dialog-based application also have startup screens. However, it is also very easy to introduce the method according to the following author. I mainly introduce the method, only by default on the picture, readers are interested in processing.
First, give a document / view application to start the screen
(1) Establish a single document / view application HS
Select the New dialog from the File menu, select the AppWizard (EXE) icon in the Projects tab. Type HS as the project name and click OK. Select the Single Document radio button in the first step, and other default options are accepted.
(2) Add startup screen
When AppWizard is complete, and Visual C opens the project, select Add to Project from the Project menu, and click Comonents and Controls on the secondary menu ..., select the Splash Screen component, as shown in Figure 1 (), single Hit INSERT. Accept all default settings.
The above steps have established an application with a main frame structure and make it a startup screen. This is what we have to do is completed.
Second, start the screen for the dialog application
(1) Establish a dialog-based application SPLA
Select the New dialog from the File menu, select the AppWizard (EXE) icon in the Projects tab. Type SPLA as the project name and click OK. Select the Dialog Based radio button in the first step, and other default options are accepted.
(2) Do the startup screen
Here, the startup screen is not inserted by using Gallery, because there is no main framework based on the dialog-based application. However, we can transplant the startup screen files established above, and then make a lot of programming modifications to the program. Please follow the steps below:
1. Copy Splash.cpp and Splash.h from the HS project into your project. Add the following code to the csplaApp's initInstance () function.
#include "splash.h" // header file please place in the start position
Bool csplaapp :: initInstance ()
CSPLASHWND :: EnableSplashscreen
2, next, use classwizard to add the oncreate function to your dialog box, and add the following code: #include "splash.h" // header file Please place in the start position
INT CSPLADLG :: OnCreate
CSPLASHWND :: ShowsplashScreen (this);
3. Copy the splash16.bmp file from the HS project to your project 蚩猈 蚩猈Space's Resouce item, insert Splash16.bmp into. Open Properties to change IDB_bitmap1 to IDB_SPLASH, this ID value is as long as it is in harmony with the program, and now makes it easiest.
You can now compile the running program, and the startup screen of Figure 2 (omitted) occurs when the program is running. This is the default picture, you can open the graphic editor yourself. If you want to change the stay time of the startup screen, modify the second parameters in Settime, here is 750 milliseconds.
INT CSPLASHWND :: OnCreate (lpcreatestruct lpcreatestruct)
// set a Timer to Destroy The Splash Screen.
Settimer (1, 750, null);