This is for Delphi 10.3, it might work in other versions too.
I don't know if you noticed, but whenever your code reachs FormCreate procedure, your FMX application will already have created a taskbar button, at least on Delphi 10.3.3 Rio, which is something we might not like. So if you use the suggested methods your application will fastly show its icon in the taskbar just to hide it.
So if you have access to Delphi's VCL/FMX source code files, and you don't like to show your application taskbar icon not even for a millisecond, you just have to modify FMX.Platform.Win.pas
file located at c:\Program Files (x86)\Embarcadero\Studio\20.0\source\fmx\
directory, then copy it to your projects directory, so it will be picked instead of the original one, and modify the CreateAppHandle
function as suggested below:
function TPlatformWin.CreateAppHandle: HWND;
var
...
begin
...
Result := CreateWindowEx(WS_EX_WINDOWEDGE or WS_EX_APPWINDOW, FMAppClass.lpszClassName, PChar(FTitle),
WS_POPUP or WS_GROUP, 0, 0, 0, 0, GetDesktopWindow, 0, hInstance, nil);
if FApplicationHWND = 0 then // modified/added line
Winapi.Windows.ShowWindow(Result, SW_HIDE) // modified/added line
else // modified/added line
Winapi.Windows.ShowWindow(Result, SW_SHOWNORMAL);
end;
That's it, you won't need the other methods, notice it also has CreateWindowEx
passing the styles for your window, if you want to hide it from Alt-Tab list too, replace WS_EX_APPWINDOW
with WS_EX_TOOLWINDOW
instead.