I have the application on Delphi with the following main form initialization:
Application.CreateForm(<class>, <variable>);
It shows the main form when the application starts.
How can I start Delphi application with the hidden main form (or on non-visual mode at all)?
To assign a different form to the MainForm property, select the form on the Project > Options > Forms dialog box at design time. MainForm cannot be modified at run time (it is read-only at run time). Note: By default, the form created by the first call to CreateForm in a project becomes the application's main form.
You can prevent the main form from appearing when your application starts Working at the Application Level. Choose Project > View Source to display the main project file. Add the following code after the call to Application. CreateForm() and before the call to Application.
Start a new project, and add one additional form (Delphi IDE Main menu: File -> New -> Form). This new form will have a 'Form2' name. Next add a TButton (Name: 'Button1') to the main form (Form1), double-click the new button and enter the following code: procedure TForm1.
In project source file set:
Application.ShowMainForm := false;
just before main form creation:
Application.CreateForm(TMainForm, MainForm);
Update from Remy:
You can also set it in the MainForm's OnCreate
event. The requirement is to set ShowMainForm
before Application.Run()
is called.
Update from gabr: Main form must also have Visible property set to False
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With