Bring the application with VC production, Xu Wei Huang Xuefeng Guangzhou University Software The People's People's Liberation Army 94782 Trigger Abstract: This article provides four startup screen production methods. Using the startup screen is a boring sensor (especially some large programs) during the waiter load process; the other is to display the information such as software name and copyright. How to use VC to make an application startup screen? This article provides four methods, the first three applications for document-based applications, and the fourth application is suitable for dialog-based applications. 1. Using the Splash Screen Components in the Component Library (1) to make the startup screen image with Photoshop, save it to the BMP format. (2) Built a single document-based project SPLASH with AppWizard. (3) Insert a bitmap resource in the resource Open the VC resource editor, right-click the Resources folder, select the import command, and insert the bitmap. If the bitmap exceeds 256 colors, the VC will pop up a dialog, prompting the bitmap has been inserted but cannot be displayed in the bitmap editor, determined. Change the bitmap ID to IDB_SPLASH. (4) Add SPLASH SCREEN Control 1 Select menu "Project" / "add to project" / "contonents and controls" Opens the dialog box, double-click the Visual C Contonents option in the list box, select the "Splash Screen" control, then single Hit "Insert". 2 Confirm or modify the class name and bitmap resource ID, click OK to confirm. 3 compiled, connected, and beautiful startup screens are displayed. (5) If you need to change the stay time of the startup screen, the second parameter of the settimer () function is modified, and the default is 750 milliseconds. This function is in location: int CsplashWnd :: oncreate (lpcreatestruct lpcreatestruct) {... // set a time to destroy the splash screen. SetTimer (1, 750, null); // Modify the second parameter to adjust the picture stay time Return 0;} 2. Display the startup screen (1) to build a single document-based project SPLASH with the APPWIZARD. (2) Import the picture used as the launch screen, change the ID to IDB_SPLASH. (3) Create a new dialog box to add a startup screen. Create a dialog in the resource, create a dialog box CSPlashDLG. Add a Picture control to the dialog box, open its "Properties" dialog, select Bitmap in the Type drop-down list, select the front-imported bitmap resource ID value in the image drop-down list: IDB_SPLASH. (4) Modify the display effect of the dialog 1 Adjust the dialog size, remove the two automatically generated buttons, and remove the choice of Title Bar in the "style" page "style" page; 2 selected image, adjust the size to make it The editable zone of the dialog is modified to "style" "Styles". (5) Add creating, display and destroy the code in the CMAINFRAME class.
#include "SplashDlg.h" // added to the file header file called MainFrm.cpp portion int CMainFrame :: OnCreate (LPCREATESTRUCT lpCreateStruct) {CSplashDlg * dlg = new CSplashDlg (this); dlg-> Create (CSplashDlg :: IDD, this); // Create a dialog DLG-> showWindow; // Display dialog DLG-> updateWindow (); Sleep (2000); // screen Show dwell time, unit is in milliseconds ... DLG-> destroyWindow () ; // Destroy the dialog RETURN 0;} 3. The step 1 to step 4 of the method 2 is repeated by sending a message display and destroying the start screen 1. 2 Add a message response function WM_Timer using Class Wizard to the CMAINFRAME class. 3) Modifying the code, by sending a WM_TIMER message start and destruction start screen 1) Define the variable of the dialog box class Add a #include "splashdlg.h" on the mainfrm.h file header, and plus common variables CSPlashDLG in the definition of the CMAINFRAM class * Splash. 2) Add timer message corresponding function code void cmainframe :: ONTIMER (splash-> iswindowvisible ()) {splash-> setActiveWindow (); // Set the boot screen to the current active window Splash-> UpdateWindow (); SLEEP (2000); // Modify this can change the screen display time splash-> sendMessage (WM_CLOSE); // Close dialog box} else {setActiveWindow (); killtimer (1); // Clear WM_TIMER Event}} 3) modify the frame generation function OnCreate () int CMainFrame :: OnCreate (LPCREATESTRUCT lpCreateStruct) {SetTimer (1,0, NULL); // add to WM_TIMER event ID of Splash 1 = new CSplashDlg (); Splash-> Create (IDD_DIALOG1 ); Splash-> showwindow (sw_show); ...} 4. Making a dialog-based application startup screen The above methods cannot be started with a dialog-based application, which is described below to dialog-based The application is started. There is no main framework based on the dialog-based application, so you cannot use the previous method to make a startup screen. However, we can transplanted the method of starting the method, then, then modify the program. (1) The reference method establishes a single document-based engineering SPLASH. (2) Establish a dialog-based engineering Cover. (3) File transplant 1 Copy Splash1.cpp and Splash1.h from the Splash project established from the method to the Cover Engineering and add it to the Source Files and Header Files, 2 import bitmap files to the project resources In the case, the ID is IDB_SPLASH.