Controlling the Windows TaskBar

The Windows TaskBar is normally located at the bottom of the screen. Most applications place a button in the TaskBar which, when clicked, causes the associated application gets focus (meaning that that application will receive keyboard input).

Rather than clicking a button, those applications included on the TaskBar can also be selected by using Alt-Tab. (I use this technique a lot.)

Actually, the MS Windows TaskBar only knows about windows objects, not applications. By using a windows handle and 2 Windows API functions, some windows can be added to, or removed from the TaskBar.

In other cases, Windows needs to be told what you want before the window is created.

Visual Basic 6.0

Visual Basic forms provide a Boolean ShowInTaskbar property. Unfortunately, even when this property is set for all forms, only the first form in an application is automatically added to the TaskBar. If you hide the main form and then display a secondary form, neither form appears in the TaskBar and there is no way to use Alt-Tab to find the secondary form. The PlaceOnTaskBar subroutine solves this problem.

Delphi 5.0

According to information on the web, WS_EX_APPWINDOW must be set when the form is created - it won't work as desired if it is set after it is created. The solution is to override TCustomForm.CreateParams (which is called before the form is created) and to set the WS_EX_APPWINDOW bit in Params.ExStyle. Reference This is additional related information from forms.pas.

This code tries to modify WS_EX_APPWINDOW at run time (after the window is created) - it does not work. (I tried replacing self with Form2 and Application, but it makes no difference.)

WS_EX_APPWINDOW is not defined in the Delphi 5 help - try searching with Google or check out Microsoft (if the link still works).

The icon displayed is controlled via Form_name.Icon (pretty obvious)

The icon is displayed under these conditions when BorderIcons=biSystemMenu

C++ Builder

This sets WS_EX_APPWINDOW before form is created. The solution is to override TForm::CreateParams (which is called before the form is created) and to set the WS_EX_APPWINDOW bit in Params.ExStyle. For more info, see the Delphi section above.

Author: Robert Clemenzi -
URL: http:// / user / clemenzi / technical / Languages / TaskBar.htm