RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TCustomApplicationEvents.OnActivate Event

Occurs when an application becomes active.

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

Write an OnActivate event handler to perform special processing when the application becomes active. 

An application becomes active when it is initially run or when focus moves from another Windows application back to any window of the application.

Note: Call the CancelDispatch method from an OnActivate event handler to prevent the application from forwarding the event to any other application events objects.
 

C++ Examples: 

 

/*
This example requires a TApplicationEvents and a TListBox
in the form.  Select the TApplicationEvents, double click
on the OnActivate event and add the following code
to the handler.  These events occur when the form gains
or loses focus.
*/
void __fastcall TAppEventForm::ApplicationEventsActivate(TObject *Sender)
{
     lbOther->Items->Add("Event OnActivate");
}

void __fastcall TAppEventForm::ApplicationEventsDeactivate(TObject *Sender)
{
    lbOther->Items->Add("Event OnDeactivate");
}

 

Delphi Examples: 

{
This example requires a TApplicationEvents and a TListBox
in the form.  Select the TApplicationEvents, double click
on the OnActivate event and add the following code
to the handler.  These events occur when the form gains
or loses focus.
}
procedure TMainForm.ApplicationEventsActivate(Sender: TObject);
begin
  lbOther.Items.Add('Event OnActivate');
end;

procedure TMainForm.ApplicationEventsDeactivate(Sender: TObject);
begin
  lbOther.Items.Add('Event OnDeactivate');
end;

 

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!