私は、1つのアプローチは、次の目的のみに役立つ「舞台裏」のメインフォームを持つことだと思っていたでしょう。
他のフォームの1つを選択してメインフォームとして表示し、古き良き「フラッシュ」画面のように永続的に非表示にします(Visible:= FALSE)。
メインフォームとして選択したフォームが閉じられたときにアプリケーションターミネーターとして機能します(適切なOnCloseイベントを配線するだけです)。
指定された疑似メインフォームに代わって他のフォームを開き、非表示の実際のメインフォームが他のフォームの「所有者」であり、「疑似メインフォーム」ではないようにすること。他のすべてのフォームが「非」ポップアップスタイルであり、ShowModalではなくShow呼び出しを介して表示される場合、これはとにかく発生するようです。
アプリケーションの動作のこの小さな再構築により、探している親切なユーザーインタラクションが得られる可能性があります。
unit FlashForm;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ExtCtrls, Vcl.StdCtrls;
type
TFlash = class(TForm)
lblTitle: TLabel;
lblCopyright: TLabel;
Timer1: TTimer;
procedure FormCreate(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
public
procedure CloseApp;
end;
var
Flash: TFlash;
implementation
{$R *.dfm}
uses Main;
procedure TFlash.CloseApp; // Call this from the Main.Form1.OnClose or CanClose (OnFormCloseQuery) event handlers
begin
close
end;
procedure TFlash.FormCreate(Sender: TObject); // You can get rid of the standard border icons if you want to
begin
lblCopyright.Caption := 'Copyright (c) 2016 AT Software Engineering Ltd';
Refresh;
Show;
BringToFront;
end;
procedure TFlash.Timer1Timer(Sender: TObject);
begin
Application.MainFormOnTaskBar := FALSE; // This keeps the taskbar icon alive
if assigned(Main.MainForm) then
begin
visible := FALSE;
Main.MainForm.Show;
Timer1.Enabled := FALSE;
end else Timer1.Interval := 10; // The initial time is longer than this (flash showing time)
end;
end.
// Finally, make this the FIRST form created by the application in the project file.