Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I start Delphi application with the hidden main form?

Tags:

delphi

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)?

like image 394
Dmitry Avatar asked Jun 26 '14 23:06

Dmitry


People also ask

How do you make a main form in Delphi?

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.

How to hide the 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.

How do I open a new form in Delphi?

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.


1 Answers

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

like image 176
Antonio Bakula Avatar answered Oct 10 '22 21:10

Antonio Bakula