1. Home
  2. Computing & Technology
  3. Delphi Programming

Hide a Delphi Application Button from the TaskBar

By , About.com Guide

The button on the Windows TaskBar, for a Delphi application, belongs to the Application window, the hidden window maintained by the Application object, not the main form window.

To hide your Delphi application (button) from the TaskBar you need to change some specific attributes of the Application window. Here's how...

procedure TMainForm.FormCreate(Sender: TObject) ;
begin
ShowWindow(Application.Handle, SW_HIDE) ;
SetWindowLong(Application.Handle, GWL_EXSTYLE, getWindowLong(Application.Handle, GWL_EXSTYLE) or WS_EX_TOOLWINDOW) ;
ShowWindow(Application.Handle, SW_SHOW) ;
end;

The code above is the handler for the TMainForm's OnCreate event. Presumably, "TMainForm" is the main form of your application.

In order to hide the button on the TaskBar you need to use the SetWindowLong API function that changes an attribute of the specified window. By applying WS_EX_TOOLWINDOW for the GWL_EXSTYLE you mark the application window as a toolbar window. A tool window does not appear in the taskbar or in the dialog box that appears when the user presses ALT+TAB.

To remove the flicker when calling the SetWindowLong, you first hide the window then show it again using ShowWindow with parameters SW_HIDE and SW_SHOW.

Not working with Delphi 2007 :(

For applications created with Delphi 2007 the above code will not work - taskbar button will not be hidden.

Here's how to Hide a Delphi 2007 Application Button from the TaskBar (with MainFormOnTaskBar)

Delphi tips navigator:
» MORE TIPS
« Desktop Screen Shot using Delphi Code

More Delphi Programming Quick Tips
Explore Delphi Programming
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. Delphi Programming
  4. Coding Delphi Applications
  5. Delphi Tips and Tricks
  6. 1999 Delphi Tips
  7. Hide a Delphi Application Button from the TaskBar

©2009 About.com, a part of The New York Times Company.

All rights reserved.