unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;
type
TForm1 =
class(TForm)
Timer1: TTimer;
procedure FormCreate(Sender: TObject);
procedure ApplicationActivate(Sender:TObject);
//procedure ApplicationMinimize(Sender:TObject);
procedure ApplicationDeactivate(Sender:TObject);
procedure Timer1Timer(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
Application.OnActivate := ApplicationActivate;
Application.OnDeactivate := ApplicationDeactivate;
end;
procedure TForm1.ApplicationActivate(Sender: TObject);
begin
Timer1.Enabled := False;
end;
procedure TForm1.ApplicationDeactivate(Sender: TObject);
begin
if not (Form1.WindowState = wsMinimized)
then
Timer1.Enabled := True;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
Timer1.Enabled := False;
Application.Minimize;
end;
end.