windowsdelphidelphi-xe3firemonkey-fm2delphi-xe4

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


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:

uses FMX.Platform.Win, Winapi.Windows;

procedure TForm1.Button1Click(Sender: TObject);
var h:THandle;
begin
  h := FmxHandleToHWND(Handle);
  ShowWindow(h, SW_HIDE);
  SetWindowLong(h, GWL_EXSTYLE, GetWindowLong(h, GWL_EXSTYLE) or WS_EX_TOOLWINDOW);
  ShowWindow(h, SW_SHOW);
end;

In XE4 this solution does not work (application button should become hidden but nothing happens). any body have any idea?

Thanks.


Solution

  • HWND hWnd = NULL;
    DWORD pid, current_pid = GetCurrentProcessId();
    do 
    {
        hWnd = FindWindowExA(NULL, hWnd, "TFMAppClass", NULL);
        if(hWnd)
        {
            GetWindowThreadProcessId(hWnd, &pid);
            if(current_pid == pid)
                break;
        }
    } while(hWnd);
    
    ::SetParent(FmxHandleToHWND(Handle), NULL);
    ::ShowWindow(hWnd, SW_HIDE);