Let the dialog-based application have startup screens

zhaozj2021-02-16  60

Let the dialog-based application include the Nanjing Navy Command (210016) Huang Yingmingyi, to make the document / view application to start the screen (1) Create a single document / view application HS Select the New Dialog from the File menu, in Projects Select the AppWizard (EXE) icon in the 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) Adding a startup screen When appwizard is complete, and Visualc opens the project, select AddToproject from the Project menu, and click Components andControls on the secondary menu ..., select the SplashScreen component, as shown in Figure 1, single Hit INSERT. Accept all default settings. The above steps have established an application program with the main frame structure and make it a startup screen. Second, to make a startup screen for a dialog-based 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) Doing the startup screen This is not inserted if you still use the Gallery to be inserted, because there is no main framework based on the dialog-based application. However, we can transplanted the startup screen files established above, then, after a little programming of the program. Follow the steps below: 1. Two files of Splash.cpp and Splash.h are copied from the HS project to your work. Add the following code to the csplaApp's initInstance () function. #Include "splash.h"

// Part-file please put it in the start

Bool csplaapp :: initInstance ()

{

CCommandLineInfo cmdinfo;

Parsecommandline (CMDInfo);

CSPLASHWND :: EnableSplashScreen (cmdinfo.m_bshow

Splash);

...

}

2. Next, use ClassWizard to add an oncreate function to your dialog box, and add the following code: #include "splash.h"

// First file Please put in the start position

INT CSPLADLG :: OnCreate

(Lpcreatestruct lpcreatestruct)

{

...

CSPLASHWND :: ShowsplashScreen (this);

...

}

3. Copy the splash16.bmp file from the HS project into your project. Open the Workspace's Resouce entry and 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 will occur 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);

Return 0;}

This program passes in VC6.0.

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

New Post(0)