fix(startup): hide the taskbar proxy too, and trace the --tray timeline
The window still showed, taskbar entry included. Two things. The taskbar button belongs to the FMX proxy window (TFMAppClass), a separate top-level window from the form — hiding the form alone never removed it. FindFMXAppWindow moves from private to public so the activate-hide can drop both. (Guarded on Assigned(FBridge): the handler is installed at line 222, the bridge is created at 268.) And rather than guess a fourth time at FMX's startup order — the same trap as the window-state saga, which only fell to instrumentation — this logs a millisecond timeline: FormCreate begin/end, the activate-hide, and the deferred MinimizeToTray. Whichever gap holds the second will be obvious. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -140,8 +140,11 @@ type
|
|||||||
procedure PrepareNid;
|
procedure PrepareNid;
|
||||||
procedure ShowTrayMenu;
|
procedure ShowTrayMenu;
|
||||||
procedure ShowFirstTimeBalloon;
|
procedure ShowFirstTimeBalloon;
|
||||||
function FindFMXAppWindow: HWND;
|
|
||||||
public
|
public
|
||||||
|
// The FMX taskbar proxy (TFMAppClass) — a SEPARATE top-level window from
|
||||||
|
// the form, and the one that owns the taskbar entry. Public so the host
|
||||||
|
// can hide it during a --tray launch, before MinimizeToTray gets to run.
|
||||||
|
function FindFMXAppWindow: HWND;
|
||||||
// Tray balloon (caller applies its own gating setting). Used for
|
// Tray balloon (caller applies its own gating setting). Used for
|
||||||
// messages the user must see while the window is hidden — e.g. an
|
// messages the user must see while the window is hidden — e.g. an
|
||||||
// autofill blocked by an elevated target.
|
// autofill blocked by an elevated target.
|
||||||
|
|||||||
@@ -220,6 +220,7 @@ begin
|
|||||||
begin
|
begin
|
||||||
Visible := False;
|
Visible := False;
|
||||||
OnActivate := TrayStartupHideOnce;
|
OnActivate := TrayStartupHideOnce;
|
||||||
|
LogLine('[tray] FormCreate begin at ' + FormatDateTime('hh:nn:ss.zzz', Now));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// The .fmx ships WindowState = wsMaximized, so that is the starting intent.
|
// The .fmx ships WindowState = wsMaximized, so that is the starting intent.
|
||||||
@@ -325,11 +326,13 @@ begin
|
|||||||
// it's noise when Windows itself put us in the tray (the user
|
// it's noise when Windows itself put us in the tray (the user
|
||||||
// didn't actively minimise). Manual launches still see it once.
|
// didn't actively minimise). Manual launches still see it once.
|
||||||
FBridge.BalloonShown := True;
|
FBridge.BalloonShown := True;
|
||||||
|
LogLine('[tray] FormCreate end at ' + FormatDateTime('hh:nn:ss.zzz', Now));
|
||||||
TThread.ForceQueue(nil,
|
TThread.ForceQueue(nil,
|
||||||
procedure
|
procedure
|
||||||
begin
|
begin
|
||||||
FBridge.MinimizeToTray;
|
FBridge.MinimizeToTray;
|
||||||
LogLine('Launched with --tray, minimised at startup (balloon suppressed)');
|
LogLine('[tray] deferred MinimizeToTray ran at ' +
|
||||||
|
FormatDateTime('hh:nn:ss.zzz', Now));
|
||||||
end);
|
end);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@@ -1600,13 +1603,22 @@ end;
|
|||||||
|
|
||||||
procedure TMainForm.TrayStartupHideOnce(Sender: TObject);
|
procedure TMainForm.TrayStartupHideOnce(Sender: TObject);
|
||||||
var
|
var
|
||||||
LHwnd: HWND;
|
LHwnd, LAppHwnd: HWND;
|
||||||
begin
|
begin
|
||||||
OnActivate := nil; // one shot — never fight the user afterwards
|
OnActivate := nil; // one shot — never fight the user afterwards
|
||||||
Visible := False;
|
Visible := False;
|
||||||
LHwnd := WindowHandleToPlatform(Self.Handle).Wnd;
|
LHwnd := WindowHandleToPlatform(Self.Handle).Wnd;
|
||||||
if LHwnd <> 0 then
|
if LHwnd <> 0 then
|
||||||
ShowWindow(LHwnd, SW_HIDE);
|
ShowWindow(LHwnd, SW_HIDE);
|
||||||
|
// The taskbar entry belongs to the FMX proxy window, not the form — hiding
|
||||||
|
// the form alone leaves the button on the taskbar.
|
||||||
|
if Assigned(FBridge) then
|
||||||
|
begin
|
||||||
|
LAppHwnd := FBridge.FindFMXAppWindow;
|
||||||
|
if LAppHwnd <> 0 then ShowWindow(LAppHwnd, SW_HIDE);
|
||||||
|
end;
|
||||||
|
LogLine('[tray] activate-hide fired at ' +
|
||||||
|
FormatDateTime('hh:nn:ss.zzz', Now));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// Single entry point for every tray restore. ExecuteAutofill really minimises
|
// Single entry point for every tray restore. ExecuteAutofill really minimises
|
||||||
|
|||||||
Reference in New Issue
Block a user