我会想到,一个办法是有一个“幕后的”主要只用于以下目的形式:
选择和显示的其他形式作为一个主窗体,然后永久隐藏自己(可见:= FALSE),就像老式的“闪光灯”屏幕一样。
当它作为主窗体选择的窗体关闭时(只需连接相应的OnClose事件),作为应用程序终止符。
要代表指定的伪主表单打开其他表单,以便隐藏的实际主表单是其他表单的“所有者”,而不是“伪主表单”。无论如何,如果所有其他表单都具有“非”弹出式样式,并且可以通过Show调用而不是ShowModal进行查看,则似乎会发生这种情况。
应用程序行为的这种小型重组可能会让您获得您所寻找的良好用户交互。
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.
提到的文章是现在[这里](http://www.stevetrefethen.com/blog/the-new-vcl-property-tapplication-mainformontaskbar-in-delphi-2007)。 – 2013-11-25 20:03:46