dkeene
asked on
Loading actions at runtime
Hi, All
I am building a component that uses prewritten actions. I searched but was unable to find a way to load actions at runtime. Can anyone post a simple example? I have already created a toolbar with buttons and images created at runtime. Thanks
Doug
I am building a component that uses prewritten actions. I searched but was unable to find a way to load actions at runtime. Can anyone post a simple example? I have already created a toolbar with buttons and images created at runtime. Thanks
Doug
No need to create the ActionList, however. I forgot to take that out before I posted.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Well, first, create your TActionList, then create a TAction for every action you want.
You MUST have an OnExecute method built to handle your actions, I would suggest
having one and assigning it to each of the TActions you create, then determine using the
Sender, what action to take when the OnExecute fires.
Then you want to assign the TAction that was created to the Action property of the
ToolbarBtn that you are creating.
Not that hard to do...
Here, I have two TButtons on a form and building actions for each.
var
i: Integer;
begin
for i := 1 to 2 do
begin
MyAction := TAction.Create(Self);
MyAction.OnExecute := Action1Execute;
MyAction.Enabled := True;
MyAction.Caption := TButton(FindComponent('But
TButton(FindComponent('But
end;