In a Delphi 10.4.2 Win32 VCL Application, I use this code to hide or show the application's TaskBar icon:
private
{ Private declarations }
FTaskBarButtonIsHidden: Boolean;
procedure TForm1.btnTestClick(Sender: TObject);
var
T: System.Win.Taskbar.TWinTaskbar;
IsOK: Boolean;
begin
T := System.Win.Taskbar.TWinTaskbar.Create;
try
if not FTaskBarButtonIsHidden then
begin
IsOK := T.DeleteTab(Self.Handle);
CodeSite.Send('TForm1.btnTestClick: DeleteTab', IsOK);
FTaskBarButtonIsHidden := IsOK;
end
else
begin
IsOK := T.AddTab(Self.Handle);
CodeSite.Send('TForm1.btnTestClick: AddTab', IsOK);
FTaskBarButtonIsHidden := not IsOK;
end;
finally
T.Free;
end;
end;
But it seems there is no way to CHECK whether the TaskBar Icon of my application is VISIBLE OR NOT.
I tried Winapi.Windows.IsWindowVisible(Self.Handle)
, but it does not work for this purpose: It always gives back True
, independently of whether the TaskBar Icon is visible or not.
How to CHECK whether the TaskBar Icon of my application is visible or not?