It takes a long time for a large application system to start and run. The time will vary according to the number of initializations required and the speed of the user's system. Therefore, an initialization window should be displayed before the main window is displayed to make the application look more attractive. Because some information can be continuously displayed to the user when the program is loaded, and beautiful visual effects can be produced. For example, both VB and Delphi display a splash window in front of the main interface when starting up.
----1. The following is a simple way to display a flash (slogan) screen splash:
optionexplicit
PRivatesubform_load()
'Show main window
me.show
'Show splash window
frmsplash.show
doevents
'Perform application initialization
initialize
'Close splash window
unloadspalsh
endsub
----This procedure code should be placed in the startup form of the application. The first show method allows Windows to display the main form on the screen, and the next show method displays the flash screen, which is a form you designed named frmsplash. After using the show method, use the Doevents function to ensure flashing All elements of the screen form are drawn immediately. The Initialize function performs time-consuming tasks that need to be performed when the application starts, such as loading data from files, loading forms into memory, and so on. At this point everything is ready.
----2. Flashing form template
----VisualBasic contains many template forms, one of which is the flash screen. To add a Splashscreen form to the project, select AddForm from the project menu. Select the SplashScreen icon on the New tab of the AddForm dialog box and click Open. The SplashScreen form is added to the project.
----The following code shows an example of how to customize the SplashScreen form template:
optionexplicit
privatesubform_load()
frmsplash.lbllicenseto=app.legaltrademarks
frmsplash.lblcompanyproduct=app.productname
frmsplash.lblplatform="window98"
frmsplash.lblcopyright=app.legalcopyright
frmsplash.lblcompany=app.companyname
frmsplash.lblwarning="Warning:thisprogramisprotected"&_
"bycopyrightlaw,sodon'tcopy"
frmsplash.show
doevents
initialize
unloadfrmsplash
endsub
----Note that the app object is used here, which can access information about your application;
----The code of the splashscreen form template code module is as follows:
PrivateSubForm_keypress(keyasciiasinteger)
unloadme
Endsub
Privatesubform_load()
lblversion.caption="version"&app.major&".
"app.minor"."app.revision
lblproductname.caption=app.title
endsub
privatesubframe1_click()
unloadme
EndSub->