功用一:在框架里面根據存儲在數據表中的方法名來動態調用執行方法。
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聲明的方法地址指針。