Use Delphi 7 to implement SPLASH form

xiaoxiao2021-03-06  52

Recently, students have done a small database management system with D7, and set a SPLASH form when the program starts running during the program. The specific implementation method is as follows: 1. Open D7 New Application, change the default form FORM1 Name property to FRMMAIN, which is the application's main form. 2, menu new> form, change the newly created form of the Name property to frMsplash, the BorderStyle property is changed to BSNE, expand the Bordericons property to set all the icons to false, empty the form title in the CAPTION property, change the position attribute PoschangeCenter, the form is a Splash form. 3, Menu Project> Options, set the main form to frmmain in the Forms tab, move frmsplash from the AUTO-CREATE FORMS on the left to the Available Forms on the right side, click OK Save Setup. 4, Menu File> Save All, will save the unit1.PAS of the code in the frmmain form to main.pas, will save the unit2.PAS of the code in the Splash form to Splash.PAS, the project file Project1.dpr Splashtest.dpr. 5, Menu Project> View Source, start writing code in Code Editor. The code is as follows: program splashtest;

Uses form, sysutils, // Note that the SYSUTILS unit is referenced because the Sleep process used by the delay is main in 'main.pas' {frmmain}, splash in 'splash.pas' {frmsplash};

{$ R * .res}

Begin Application.initialize;

FRMSPLASH: = TFRMSPLASH.CREATE (FRMSPLASH); // Dynamically Create frMsplash form frmsplash.show; // Display frMsplash form frmsplash.Update; Sleep (2000); // delay 2 seconds

Application.createform (tfrmmain, frmmain);

FRMSPLASH.HIDE; / / Hide FRMSPLASH Form FRMSPLASH.FREE; / / Release FRMSPLASH Form

Application.run; end. After writing, press F9 to run this project. Will see the Splash form first appear, the SPLASH form disappears after the delay is over, and the frmmain form is displayed. Summary: 1. The key here is that frmsplash is not automatically created when the application is running, but by dynamically created, first to move frmsplash from Auto-Create Forms to Available Forms, followed by manually writing code to complete frMsplash The creation and release of the form. 2, if the Sleep process is not used, the FRMSPLASH form is also flashing, and it is not possible to prompt the information, so the SLEEP process in which the SYSUTILS unit must be referenced to the time.

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

New Post(0)