Based on David's answer I've made a small example:
program Project1;
uses
ExceptionLog,
Forms,
Unit2 in 'Unit2.pas' {Form2},
AppEvnts,
Classes,
Windows,
SysUtils;
{$R *.res}
type TAppEventsHack = class
procedure onAppEvtExec(Action:TBasicAction;var Handled:Boolean);
end;
var aEvHack : TAppEventsHack;
aAppEvents : TApplicationEvents;
{ TAppEventsHack }
procedure TAppEventsHack.onAppEvtExec(Action: TBasicAction;
var Handled: Boolean);
begin
OutputDebugString(PAnsiChar(Action.Name));
Handled := False;
end;
begin
Application.Initialize;
try
aEvHack := TAppEventsHack.Create;
aAppEvents := TApplicationEvents.Create(nil);
aAppEvents.OnActionExecute := aEvHack.onAppEvtExec;
Application.CreateForm(TForm2, Form2);
Application.Run;
finally
freeandnil(aEvHack);
freeandnil(aAppEvents);
end;
end.
TApplication.OnActionExecute
event is the second hook that processes aTAction
. If theTAction
is associated with aTActionList
, theTActionList.OnExecute
event gets first dibs on theTAction
. If that event handler returns True, theTApplication.OnActionExecute
event is NOT triggered. – Stadtholder