From 169cdddf9d9a243c0c88d9fc7ab687ce138dbae9 Mon Sep 17 00:00:00 2001 From: r-zakarya <82443831+r-zakarya@users.noreply.github.com> Date: Mon, 27 Jul 2026 05:35:58 +0100 Subject: [PATCH] fix(startup): hide the --tray window from the .dpr, where it sticks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Setting Visible := False in FormCreate wasn't enough — FMX re-shows the main form after the constructor returns, so the window still appeared for ~1 s during the Windows logon. Do it in the .dpr instead, between CreateForm and Run: that is after FMX's own show and before any message is pumped, so nothing ever paints. Backed by a Win32 ShowWindow(SW_HIDE) so it holds whatever FMX decides. The handle is still created, so WebView2 initialises normally and the vault is ready as soon as the user clicks the tray icon. The taskbar entry can still appear briefly; the deferred MinimizeToTray drops it, along with adding the tray icon. Co-Authored-By: Claude Opus 4.8 --- delphi-backend/PMServer.dpr | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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.