private
procedure ExecMethod(OnObject: TObject; MethodName: string) ;
end;
var
Form1: TForm1;
type
TExec = procedure of object;
procedure TForm1.ExecMethod(OnObject: TObject; MethodName: string) ;
var
Routine: TMethod;
Exec: TExec;
begin
Routine.Data := Pointer(OnObject) ;
Routine.Code := onObject.MethodAddress(MethodName) ;
if NOT Assigned(Routine.Code) then Exit;
Exec := TExec(Routine) ;
Exec;
end;
procedure TForm1.CallMeByName(Sender: TObject) ;
begin
ShowMessage('Hello Delphi!') ;
end;
procedure TForm1.Button1Click(Sender: TObject) ;
begin
ExecMethod(Form1, 'CallMeByName') ;
end;
'델파이 > 델파이관련' 카테고리의 다른 글
RichEdit Message Interface (0) | 2011.09.28 |
---|---|
Delphi Memo 에서 현재 Line 과 Column 알아내기 (0) | 2011.09.28 |
Delphi Video Capture Component (0) | 2011.04.14 |
델파이 함수 (0) | 2011.03.09 |
Delphi 2009, 2010 DataSnap (0) | 2011.02.26 |