OnActionExecute (C++)

From RAD Studio Code Examples
Jump to: navigation, search


This example requires a TApplicationEvents, a TActionList, and a TListBox on the form. Select the TApplicationEvents, double-click the OnActionExecute event, and add the following code to the handler. Create a TAction, named MyAction, in a TActionList. The TActionList must have no OnExecute event handler, and the TAction has an OnExecute event handler, called MyActionExecute. Then set an object's (such as a button) Action to MyAction. The Handled parameter of the event handler returns False by default. If the handler handles the event, it should change Handled to True, thereby preventing further attempts to handle the action.


void __fastcall TAppEventForm::ApplicationEventsActionExecute(
      TBasicAction *Action, bool &Handled)
    lbOther->Items->Add("Event OnActionExecute");

void __fastcall TAppEventForm::ActionExecute(TObject *Sender)
	ShowMessage("Action executed");