Have an amazing solution built in RAD Studio? Let us know. Looking for discounts? Visit our Special Offers page!
Delphi

Hiding your application from the Windows Taskbar.

the future of starts demands massive productivity

Author: Embarcadero USA

Question:

How do I hide my application from the Windows Taskbar?

Answer:

It is possible to have your application running without an icon appearing in the task bar. Here’s how to do this:

  • In Delphi go to the menu option Project -> View Source.
  • Add the Windows unit to the uses clause.
  • Add Application.ShowMainForm := False; to the line after
    “Application.Initialize;”.
  • Add: ShowWindow(Application.Handle, SW_HIDE); to the line
    before “Application.Run;”
  • If you still want your form to show then Add: ShowWindow(Form1.Handle, SW_SHOWNORMAL); to the line just before “Application.Run;”

    Your main project source file should now look something like
    this:

    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);
      ShowWindow(Form1.Handle, SW_SHOWNORMAL); //Only add this if you want your form to show.
      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.
    

    Article originally contributed by


Reduce development time and get to market faster with RAD Studio, Delphi, or C++Builder.
Design. Code. Compile. Deploy.
Start Free Trial   Upgrade Today

   Free Delphi Community Edition   Free C++Builder Community Edition

Related posts
DelphiTech Partner

Native thumbnail and preview functionality for your software: ShellBrowser Delphi Components

News

Using C++17 Algorithms Library Parallel Sorting with C++Builder 10.4 Sydney for Win32 and Win64

C++

What's New in the GetIt Package Manager - June 2020

C++

RAD Studio 10.4 Now Available, Learn More

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

IN THE ARTICLES