1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
| unit essai_liste_actions;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, StdActns, Menus, ActnList, Buttons, ExtCtrls;
type
TForm1 = class(TForm)
ActionList1: TActionList;
Action1: TAction;
Action2: TAction;
procedure FormCreate(Sender: TObject);
procedure Action1Execute(Sender: TObject);
procedure Action2Execute(Sender: TObject);
private
{ Déclarations privées }
public
{ Déclarations publiques }
end;
var
Form1: TForm1;
ipos: integer;
implementation
{$R *.dfm}
Procedure ExecAction(ActionList :TCustomActionList;Ipos : Integer);
Var
A : TAction;
begin
if Not Assigned(ActionList) then
showmessage('perdu')
else
begin
A := TAction(ActionList.Actions[Ipos]);
A.Execute;
end;
end;
///////////////
procedure TForm1.FormCreate(Sender: TObject);
begin
ExecAction(ActionList1,0);
end;
procedure TForm1.Action1Execute(Sender: TObject);
begin
showmessage('action1');
end;
////////////////////////
procedure TForm1.Action2Execute(Sender: TObject);
begin
showmessage('action2');
end;
begin
if Assigned(Form1) then ExecAction(Form1.ActionList1,0);
end. |
Partager