fix(startup): hide the --tray window from the .dpr, where it sticks
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 <noreply@anthropic.com>
This commit is contained in:
@@ -1,8 +1,11 @@
|
|||||||
program PMServer;
|
program PMServer;
|
||||||
|
|
||||||
uses
|
uses
|
||||||
|
Winapi.Windows,
|
||||||
|
System.SysUtils,
|
||||||
System.StartUpCopy,
|
System.StartUpCopy,
|
||||||
FMX.Forms,
|
FMX.Forms,
|
||||||
|
FMX.Platform.Win,
|
||||||
PM.SingleInstance in 'Source\PM.SingleInstance.pas',
|
PM.SingleInstance in 'Source\PM.SingleInstance.pas',
|
||||||
UMainForm in 'UMainForm.pas' {MainForm},
|
UMainForm in 'UMainForm.pas' {MainForm},
|
||||||
PM.JSON in 'Source\PM.JSON.pas',
|
PM.JSON in 'Source\PM.JSON.pas',
|
||||||
@@ -44,5 +47,18 @@ begin
|
|||||||
|
|
||||||
Application.Initialize;
|
Application.Initialize;
|
||||||
Application.CreateForm(TMainForm, MainForm);
|
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;
|
Application.Run;
|
||||||
end.
|
end.
|
||||||
|
|||||||
Reference in New Issue
Block a user