diff --git a/delphi-backend/PMServer.dpr b/delphi-backend/PMServer.dpr index b1b5730..9b57c3a 100644 --- a/delphi-backend/PMServer.dpr +++ b/delphi-backend/PMServer.dpr @@ -1,8 +1,11 @@ program PMServer; uses + Winapi.Windows, + System.SysUtils, System.StartUpCopy, FMX.Forms, + FMX.Platform.Win, PM.SingleInstance in 'Source\PM.SingleInstance.pas', UMainForm in 'UMainForm.pas' {MainForm}, PM.JSON in 'Source\PM.JSON.pas', @@ -44,5 +47,18 @@ begin Application.Initialize; Application.CreateForm(TMainForm, MainForm); + // --tray ("Start with Windows"): keep the window off screen entirely. + // FormCreate already sets Visible := False, but FMX re-shows the main form + // after the constructor returns, which is why the window still flashed for + // ~1 s during the Windows logon. Doing it HERE — after CreateForm, before + // Run pumps any message — is the point where it sticks. The handle still + // exists, so WebView2 initialises normally and the vault is ready the + // moment the user clicks the tray icon. + if FindCmdLineSwitch('tray', True) then + begin + MainForm.Visible := False; + if MainForm.Handle <> nil then + ShowWindow(WindowHandleToPlatform(MainForm.Handle).Wnd, SW_HIDE); + end; Application.Run; end.