The problem is: How to hide additional form when application minimizes because after application restores, additional form can't be closed. Attached code shows the behavior. First I open additional form by pressing button. It has set Form Style set fsStayOnTop. Then I press timer button and minimize main form. After timer restores forms the additional one can't be closed.
program MINIBUG;
uses
Vcl.Forms,
MainForm in 'MainForm.pas' {Form7},
AddForm in 'AddForm.pas' {Form8};
{$R *.res}
begin
Application.Initialize;
Application.MainFormOnTaskbar := True;
Application.CreateForm(TForm7, Form7);
Application.CreateForm(TForm8, Form8);
Application.Run;
end.
unit AddForm;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs;
type
TForm8 = class(TForm)
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form8: TForm8;
implementation
{$R *.dfm}
end.
unit MainForm;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, AddForm, Vcl.ExtCtrls;
type
TForm7 = class(TForm)
btnAddForm: TButton;
tmr1: TTimer;
Button1: TButton;
procedure btnAddFormClick(Sender: TObject);
procedure tmr1Timer(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form7: TForm7;
implementation
{$R *.dfm}
procedure TForm7.btnAddFormClick(Sender: TObject);
begin
Form8.Show;
end;
procedure TForm7.Button1Click(Sender: TObject);
begin
tmr1.Enabled := True;
end;
procedure TForm7.tmr1Timer(Sender: TObject);
begin
tmr1.Enabled := False;
form8.Close;
Application.Restore;
end;
end.