16,748
社区成员
发帖
与我相关
我的任务
分享
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
published
procedure Test(Msg: string);
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
type
TTestMethod = procedure (Msg: string) of object;
var
vWinControl: TWinControl;
vMethodAddress: Pointer;
vMethod: TMethod;
begin
vWinControl := FindControl(Handle);
if not Assigned(vWinControl) then Exit;
vMethodAddress := vWinControl.MethodAddress('Test');
if not Assigned(vMethodAddress) then Exit;
vMethod.Code := vMethodAddress;
vMethod.Data := vWinControl;
TTestMethod(vMethod)('Zswang 路过');
end;
procedure TForm1.Test(Msg: string);
begin
ShowMessage(Name + '.' + Msg);
end;