RAD Studio
ContentsIndex
PreviousUpNext
Updating Actions

When the application is idle, the OnUpdate event occurs for every action that is linked to a control or menu item that is showing. This provides an opportunity for applications to execute centralized code for enabling and disabling, checking and unchecking, and so on. For example, the following code illustrates the OnUpdate event handler for an action that is "checked" when the toolbar is visible:

procedure TForm1.Action1Update(Sender: TObject);
begin
{ Indicate whether ToolBar1 is currently visible }
(Sender as TAction).Checked := ToolBar1.Visible;
end;

 

void __fastcall TForm1::Action1Update(TObject *Sender)
{
// Indicate whether ToolBar1 is currently visible
((TAction *)Sender)->Checked = ToolBar1->Visible;
}

Warning: Do not add time-intensive code to the OnUpdate event handler. This executes whenever the application is idle. If the event handler takes too much time, it will adversely affect performance of the entire application.

TActionList 

TAction 

TActionLink

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