RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TApplication.OnDeactivate Event

Occurs when an application becomes inactive.

Pascal
property OnDeactivate: TNotifyEvent;
C++
__property TNotifyEvent OnDeactivate;

Write an OnDeactivate event handler to perform any special processing that should occur immediately before the application is deactivated. The OnDeactivate event occurs when the user switches from the application to another Windows application.

Note: You can also respond to this event using the TApplicationEvents component, which allows you to assign an event handler using the IDE.
 

C++ Examples: 

 

/*
The following code minimizes an application when it’s
deactivated. Note that AppDeactivate should be declared a
method of TForm1.  Click anywhere outside of the form
to deactivate it.
*/
void __fastcall TForm1::AppDeactivate(TObject *Sender)
{
  Application->Minimize();
}

void __fastcall TForm1::FormCreate(TObject *Sender)
{
  Application->OnDeactivate = AppDeactivate;
}

 

Delphi Examples: 

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

 

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!