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
Delphi 5.0
type TForm2 = class(TForm) private { Private declarations } public { Public declarations } procedure CreateParams(var Params:TCreateParams); override; end; procedure TForm2.CreateParams(var Params:TCreateParams); begin inherited CreateParams(Params); Params.ExStyle := Params.ExStyle or WS_EX_APPWINDOW; Params.WndParent := GetDesktopWindow; end;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.)
procedure TForm2.Button1Click(Sender: TObject); var lRetVal: integer; begin lRetVal := GetWindowLong(self.Handle, GWL_EXSTYLE); If CheckBox1.checked = true Then // Modify the style bits to show on the task bar lRetVal := lRetVal Or WS_EX_APPWINDOW Else // Modify the style bits to delete from the task bar lRetVal := lRetVal And Not WS_EX_APPWINDOW ; // Set the new style bits lRetVal := SetWindowLong(self.Handle, GWL_EXSTYLE, lRetVal); end;
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
Form_name.BorderStyle | Icon Visible | Close Button (x) | |||
---|---|---|---|---|---|
bsDialog | No | Yes | |||
bsNone | No | No | |||
bsSingle | Yes | Yes | |||
bsSizeable | Yes | Yes | |||
bsToolWindow | No | Yes | |||
bsSizeToolWin | No | Yes |
C++ Builder
class TForm2 : public TForm { __published: // IDE-managed Components private: // User declarations public: // User declarations __fastcall TForm2(TComponent* Owner); void __fastcall CreateParams(Controls::TCreateParams &Params); }; void __fastcall TForm2::CreateParams(Controls::TCreateParams &Params) { TForm::CreateParams(Params); Params.ExStyle = Params.ExStyle | WS_EX_APPWINDOW; Params.WndParent = ParentWindow; }For more info, see the Delphi section above. Author: Robert Clemenzi - clemenzi@cpcug.org