diff --git a/delphi-backend/UMainForm.pas b/delphi-backend/UMainForm.pas index ca06c3b..62a2c86 100644 --- a/delphi-backend/UMainForm.pas +++ b/delphi-backend/UMainForm.pas @@ -206,6 +206,16 @@ procedure WinStateEventProc(hWinEventHook: THandle; AEvent: DWORD; AWnd: HWND; procedure TMainForm.FormCreate(Sender: TObject); begin + // --tray (the "Start with Windows" registry entry): never let the window + // become visible at all. Hiding it later — even via ForceQueue — only runs + // once the message loop is free, i.e. AFTER the DB open, the HTTP server + // start and the WebView2 init have finished, so the window sat on screen + // for a second or two during the Windows logon. Setting Visible here, before + // any of that, means there is nothing to flash. MinimizeToTray still runs + // below to add the tray icon and drop the taskbar entry. + if FindCmdLineSwitch('tray', True) then + Visible := False; + // The .fmx ships WindowState = wsMaximized, so that is the starting intent. // Wired here (not in the .fmx) to keep the designer file untouched. FWantMaximized := (WindowState = TWindowState.wsMaximized); @@ -300,8 +310,9 @@ begin // CLI flag --tray (set by the "Start with Windows" registry entry): // launch directly into the tray instead of popping a window during - // the Windows login. Defer to ForceQueue so the form has finished its - // initial Show before we hide it — minimises the visible flash. + // the Windows login. The window was already made invisible at the top of + // FormCreate; this adds the tray icon and drops the taskbar entry. Still + // deferred: it is also the safety net if FMX shows the main form anyway. if FindCmdLineSwitch('tray', True) then begin // Suppress the first-time tray balloon for autostart launches —