How to hide firemonkey application button from Taskbar (XE4)?

后端 未结 4 867
天命终不由人
天命终不由人 2020-12-18 11:13

According to this question it is possible to hide fmx taskbar icon by changing window style to WS_EX_TOOLWINDOW. In XE2 and XE3 this code works:

<         


        
4条回答
  •  情深已故
    2020-12-18 12:03

    Just tried this in XE7 and of course it didn't work. However a little look into FMX.PlatformWin shows the application handle is now exposed through the ApplicationHWND function, so the code that works on XE7 (don't forget to include unit FMX.Platform.Win and Winapi.Windows) is...

    procedure HideAppOnTaskbar (AMainForm : TForm);
    var
      AppHandle : HWND;
    begin
      AppHandle := ApplicationHWND; 
      ShowWindow(AppHandle, SW_HIDE);
      SetWindowLong(AppHandle, GWL_EXSTYLE, GetWindowLong(AppHandle, GWL_EXSTYLE) and (not     WS_EX_APPWINDOW) or WS_EX_TOOLWINDOW);
      //ShowWindow(AppHandle, SW_SHOW);
    end;
    

    The ShowWindow at the end is optional - it seems to make no difference. You can remove the extended styles and restore the WS_EX_APPWINDOW style to show the toolbar icon again.

提交回复
热议问题