以下代码仅仅是测试代码:delphi XE7 UP1
- interface
-
- uses
- Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
- System.Classes, Vcl.Graphics,
- Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;
-
- type
- TForm1 = class(TForm)
- btn1: TButton;
- btn2: TButton;
- edt1: TEdit;
- procedure btn1Click(Sender: TObject);
- procedure FormCreate(Sender: TObject);
- procedure FormShow(Sender: TObject);
- procedure FormDestroy(Sender: TObject);
- private
-
-
- public
-
- end;
-
- TMethod = procedure(v:string);
- var
- Form1: TForm1;
- FList: TList;
-
- implementation
-
- {$R *.dfm}
-
- procedure p1(v:string);
- begin
- ShowMessage('p1'+v);
- end;
-
- procedure p2(v:string);
- begin
- ShowMessage('p2'+v);
- end;
-
-
-
- procedure callt(my:TMethod;v:string);
- begin
- my(v);
- end;
-
-
-
- procedure TForm1.btn1Click(Sender: TObject);
- var
- v_s:string;
- begin
- v_s:= edt1.Text;
- callt(FList.Items[StrToInt(v_s)],v_s);
- end;
-
- procedure TForm1.FormCreate(Sender: TObject);
- begin
- FList := TList.Create;
- end;
-
- procedure TForm1.FormShow(Sender: TObject);
- begin
- FList.Add(@p1);
- FList.Add(@p2);
- edt1.Clear;
- end;
-
- procedure TForm1.FormDestroy(Sender: TObject);
- begin
- FreeAndNil(FList);
- end;
-
- end.
-
http://blog.csdn.net/rznice/article/details/43190537
|
请发表评论