{
The following code minimizes an application when it’s deactivated. Note that AppDeactivate should be declared a method of TForm1.
} 
procedure TForm1.FormCreate(Sender: TObject);
begin
  Application.OnDeactivate := AppDeactivate;
end;
procedure TForm1.AppDeactivate(Sender: TObject);
begin
  Application.Minimize;
end;
