unit mainU;
interface
uses
Winapi.Windows,
Winapi.Messages, System.SysUtils, System.Variants, System.Classes,
Vcl.Graphics,
Vcl.Controls,
Vcl.Forms,
Vcl.Dialogs,
Vcl.StdCtrls,core;
type
TMyEventHandler =
procedure (Sender:TObject;
const param1:
String)
of object;
TMyEventHandler2 =
procedure (Sender:TObject;
const param1, param2:
String)
of object;
type
TForm52 =
class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
mylist : TMylist;
public
procedure MyEventHandler(Sender:TObject;
const param1:
String);
procedure MyEventHandler2(Sender: TObject;
const param1, param2:
String);
end;
var
Form52: TForm52;
implementation
{$R *.dfm}
procedure TForm52.Button1Click(Sender: TObject);
begin
mylist.SetEvent<TMyEventHandler>('
Event', MyEventHandler);
mylist.SetEvent<TMyEventHandler2>('
Event2', MyEventHandler2);
end;
procedure TForm52.Button2Click(Sender: TObject);
begin
MyList.GetEvent<TMyEventHandler>('
Event')(
nil, '
Wupti');
end;
procedure TForm52.Button3Click(Sender: TObject);
begin
MyList.GetEvent<TMyEventHandler2>('
Event2')(
nil, '
Wupti', '
Hallo');
end;
procedure TForm52.FormCreate(Sender: TObject);
begin
mylist := TMyList.create;
end;
procedure TForm52.FormDestroy(Sender: TObject);
begin
mylist.free;
end;
procedure TForm52.MyEventHandler(Sender: TObject;
const param1:
string);
begin
ShowMessage(Param1);
end;
procedure TForm52.MyEventHandler2(Sender: TObject;
const param1, param2:
String);
begin
ShowMessage(Param1 + #13 + Param2);
end;
end.