diff --git a/delphi-backend/UMainForm.pas b/delphi-backend/UMainForm.pas index cabb1f5..e46a6b0 100644 --- a/delphi-backend/UMainForm.pas +++ b/delphi-backend/UMainForm.pas @@ -342,7 +342,18 @@ begin FreeAndNil(configList); end; end; - btnStartClick(Nil); + // Starting the server (DB open + Indy bind + WebView2 navigation) is what + // makes FormCreate run for ~1 s. The FMX taskbar proxy is created somewhere + // inside that second, and since the thread never pumps a message while it + // runs, nothing can hide the proxy until it is over — that is the taskbar + // button sitting there during the Windows logon. + // + // On a --tray launch, do it AFTER the tray hide instead: FormCreate then + // returns in milliseconds, MinimizeToTray runs immediately, and the proxy is + // gone before it can be drawn. A normal launch is unchanged (the window is + // meant to be on screen anyway, so ordering does not matter there). + if not FindCmdLineSwitch('tray', True) then + btnStartClick(Nil); btnToggleLogClick(nil); // CLI flag --tray (set by the "Start with Windows" registry entry): @@ -361,6 +372,8 @@ begin procedure begin FBridge.MinimizeToTray; + // Hidden now — safe to pay the startup cost. + btnStartClick(Nil); GTrayStartupPending := False; if FShowEventHook <> 0 then begin