功用一:在框架里面根据存储在数据表中的方法名来动态调用执行方法。
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure FormCreate(Sender: TObject);
published
procedure Test(Sender: TObject);
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
{ TForm1 }
procedure TForm1.Test(Sender: TObject);
begin
ShowMessage('hello');
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
@Button1.OnClick := MethodAddress('test')
end;
end.
注:MethodAddress()只能获取published声明的方法地址指针。