14

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

JJJ
  • 32,902
  • 20
  • 89
  • 102
Dmitry
  • 14,306
  • 23
  • 105
  • 189

1 Answers1

22

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

Antonio Bakula
  • 20,445
  • 6
  • 75
  • 102
  • 9
    You can also set it in the MainForm's `OnCreate` event. The requirement is to set `ShowMainForm` before `Application.Run()` is called. – Remy Lebeau Jun 26 '14 at 23:39
  • 1
    Is it possible to keep the taskbar icon visible? I have a login form which only makes the main form visible once login succeeds, but then there's no taskbar icon (or alt-tab thumbnail). Sorry for wanting my cake and eating it :) – Reversed Engineer Jun 28 '17 at 10:35
  • @DaveBoltman Instead of hiding the form just set the forms WindowState to wsMinimized. – Toby Nov 18 '17 at 00:00
  • 1
    Main form must also have `Visible` property set to `False`. – gabr Jun 22 '18 at 14:58