Hiding your application from the Windows Taskbar.

Question:

How do I hide my application from the Windows Taskbar?

Answer:

To do this you will need to:

  1. Select the View -> Project Source, from Delphi's main menu.

  2. Add the Windows unit to the uses clause.

  3. Add Application.ShowMainForm := False; to the line after "Application.Initialize;".

  4. Add: ShowWindow(Application.Handle, SW_HIDE); to the line before "Application.Run;"

Your main project source file should now look something likethis:

program Project1;

uses

  Windows,

  Forms,

  Unit1 in 'Unit1.pas' {Form1},

  Unit2 in 'Unit2.pas' {Form2};

 

{$R *.RES}

 

begin

  Application.Initialize;

  Application.ShowMainForm := False;

  Application.CreateForm(TForm1, Form1);

  Application.CreateForm(TForm2, Form2);

  ShowWindow(Application.Handle, SW_HIDE);

  Application.Run;

end.

In the "initialization" section (at the very bottom) of each unit that uses a form, add:

begin

  ShowWindow(Application.Handle, SW_HIDE);

end.