Posted by webmaster Guido on October 24, 2002 In Reply to: Delphi splash form with command line parameters posted
by QWERTYX85 on October 19, 2002
Let's rewrite what you tried, giving easier names to the forms: FormSplash.Visible := (ParamStr(1) <> 'nosplash'); FormMain.Visible := True; Problem: before a form's property "Visible" can be set, the form must be created. Normally, Delphi automatically creates the forms. The first form that is auto-created, becomes the application's "main form", and it is automatically shown after all the forms are created, by this line in the .DPR file: So, the line "FormMain.Visible := True" is not necessary. But before the auto-creation of FormMain, we must: 1. Create FormSplash, but only if the command line parameters don't specify "nosplash". This is done by adding some code to the project file. Right before FormMain is shown, we must hide FormSplash, but only if it was created before. Finally, we must make sure that FormSplash is not auto-created, by moving it from the list of auto-created forms. In Delphi's menu, select Project/Options, select FormSplash in the column with the auto-created forms, and click the button to move it to the other column with the "not automatically created forms". Here's an example of a modified .DPR file: program SplashTest; uses Forms, Main in 'Main.pas' {FormMain}, Splash in 'Splash.pas' {FormSplash}; {$R *.RES} begin Application.Initialize; if ParamStr(1) <> 'nosplash' then begin FormSplash := TFormSplash.Create(Application); FormSplash.Show; FormSplash.Update; end; Application.CreateForm(TFormMain, FormMain); if ParamStr(1) <> 'nosplash' then FormSplash.Close; Application.Run; end. With this code, in most cases you won't see the splash form, because it's only shown for a very short time. So you might want to add code for a delay of a few seconds before closing FormSplash.
Find related articles Search for: command line pass parameters application parameters splash form
|
|