TechTricks
Technical answers from the trenches 
 
 
 
 

     
   
Hiding Applications from the Taskbar
 
   
 Posted: 3 February 2003
 
   
Multiple sources 
 Applies to: Most Versions
 
   
 
Audience: Beginner
 
       
   

Question: How do I keep my Delphi application from appearing on the Taskbar?

Answer: Add the following code to the main form's OnCreate event:

  SetWindowLong( application.handle, GWL_EXSTYLE,
     GetWindowLong( application.handle, GWL_EXSTYLE )
     or WS_EX_TOOLWINDOW and not WS_EX_APPWINDOW );

How it works

This modifies your form's underlying window class and prevents your application from appearing in the Taskbar in two cases: 1) while the application is running normally and 2) when the application is minimized.

More information can be found in the Help topics for the CreateWindow and CreateWindowEx API functions. Pay particular attention to the various window style flags that can be used with window classes. These and related topics are can be found in the Win32 Developer's Reference Help file provided with Delphi.

Warning: Applications using this code may appear to "disappear" when all Desktop windows are minimized and the Taskbar hides itself automatically. This happens because the Taskbar automatically displays itself when all Desktop windows are minimized. To locate your minimized application, simply start or switch focus to a different application. When you do this, the Taskbar hides itself, which in turn reveals your hidden application's icon near the lower left corner of the Desktop.

Note: Some online sources also tell you to add

Application.ShowMainForm := FALSE;
to your project source file (before the Application.Run line). In our testing, you don't need to do this to hide applications from the Taskbar. (It does help create applications that start as icons in the Tasktray, but that will be discussed in a future article.)

 

       

Top

Feedback About Paradox Delphi Assorted Web Stuff
 
 
Copyright © 2000-2004, techtricks.com; All Rights Reserved.
Acknowledgements, Disclaimers, Terms and Conditions.
Article last updated on 31 May 2003

 

Other Sites: Paradox, Delphi, Perl, Web Stuff, and More


 

[- End -]