Unlike VCL, FMX hides Win32 window messages from you. And, it ignores most window messages in general, it only handles a handful of select messages for its own purpose.
Since you are forcing the Taskbar button to appear on a sub-Form, you will have to manually subclass the Form's window so you can handle window messages like WM_ACTIVATE, eg:
type
TSubToolBarForm = class(TForm)
private
...
{$IFDEF MSWINDOWS}
protected
procedure CreateHandle; override;
{$ENDIF}
...
end;
...
{$IFDEF MSWINDOWS}
uses
Winapi.Windows,
Winapi.Messages,
Winapi.CommCtrl,
FMX.Platform.Win;
function SubToolBarSubclassProc(Wnd: HWND; uMsg: UINT; wParam: WPARAM; lParam: LPARAM;
uIdSubclass: UINT_PTR; dwRefData: DWORD_PTR): LRESULT; stdcall;
begin
case uMsg of
WM_NCDESTROY: begin
RemoveWindowSubclass(Wnd, SubToolBarSubclassProc, uIdSubclass);
end;
WM_ACTIVATE: begin
if wParam in [WA_ACTIVE, WA_CLICKACTIVE] then
begin
SetFocus(Wnd);
//SetForeGroundWindow(Wnd);
//BringWindowToTop(Wnd);
end;
end;
end;
Result := DefSubclassProc(Wnd, uMsg, wParam, lParam);
end;
procedure TSubToolBarForm.CreateHandle;
var
Wnd: HWND;
ExStyle: LONG_PTR;
begin
inherited;
Wnd := FormToHWND(Self);
ExStyle := GetWindowLongPtr(Wnd, GWL_EXSTYLE);
SetWindowLong(Wnd, GWL_EXSTYLE, ExStyle or WS_EX_APPWINDOW);
SetWindowSubclass(Wnd, SubclassProc, 1, DWORD_PTR(Self));
end;
{$ENDIF}