169cdddf9d
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>
65 lines
2.5 KiB
ObjectPascal
65 lines
2.5 KiB
ObjectPascal
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',
|
|
PM.Database in 'Source\PM.Database.pas',
|
|
PM.Router in 'Source\PM.Router.pas',
|
|
PM.StaticFiles in 'Source\PM.StaticFiles.pas',
|
|
PM.EmbeddedAssets in 'Source\PM.EmbeddedAssets.pas',
|
|
PM.Crypto in 'Source\PM.Crypto.pas',
|
|
PM.RateLimit in 'Source\PM.RateLimit.pas',
|
|
PM.Audit in 'Source\PM.Audit.pas',
|
|
PM.Session in 'Source\PM.Session.pas',
|
|
PM.HTTPServer in 'Source\PM.HTTPServer.pas',
|
|
PM.Bridge in 'Source\PM.Bridge.pas',
|
|
PM.QuickUnlock in 'Source\PM.QuickUnlock.pas',
|
|
PM.PinUnlock in 'Source\PM.PinUnlock.pas',
|
|
PM.UserPrefs in 'Source\PM.UserPrefs.pas',
|
|
PM.AutoStart in 'Source\PM.AutoStart.pas',
|
|
PM.Favicon in 'Source\PM.Favicon.pas',
|
|
PM.ProcessLockdown in 'Source\PM.ProcessLockdown.pas',
|
|
PM.Handler.Ping in 'Handlers\PM.Handler.Ping.pas',
|
|
PM.Handler.Auth in 'Handlers\PM.Handler.Auth.pas',
|
|
PM.Handler.Folders in 'Handlers\PM.Handler.Folders.pas',
|
|
PM.Handler.Entries in 'Handlers\PM.Handler.Entries.pas',
|
|
PM.Handler.Passkey in 'Handlers\PM.Handler.Passkey.pas',
|
|
PM.Handler.Recovery in 'Handlers\PM.Handler.Recovery.pas',
|
|
PM.Handler.Audit in 'Handlers\PM.Handler.Audit.pas',
|
|
PM.Handler.Settings in 'Handlers\PM.Handler.Settings.pas',
|
|
PM.Handler.Attachments in 'Handlers\PM.Handler.Attachments.pas';
|
|
|
|
{$R *.res}
|
|
{$R assets\assets.res}
|
|
|
|
begin
|
|
// Single-instance: if another PMServer is running, bring it to front
|
|
// (it'll handle WM_PMSHOW on its message-only window) and exit. Avoids
|
|
// two icons in the tray and two HTTP servers fighting for the port.
|
|
if not PM.SingleInstance.AcquireOrSignal then
|
|
Exit;
|
|
|
|
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.
|