const
WM_MYMSG=wm_user+9;
type
TExternalDLL=function( para1:string;para2:integer):string;
TMyObject=class
name:string;
age:integer;
info:string;
procedure callExternalDLL(func:TExternalDLL);
procedure responseMessage( var msg:tmessage)
message WM_MYMSG;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
var
myObj:TMyObject;
function doIt(para1:string;para2:integer):string;
begin
result:='Your info is: '+
'name:'+para1+
'age:'+inttostr(para2);
end;
{ TMyObject }
procedure TMyObject.callExternalDLL(func: TExternalDLL);
begin
info:=func(name,age);
end;
procedure TMyObject.responseMessage(var msg: tmessage);
begin
showmessage('hello,response to the message WM_MYMSG');
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
showmessage(myObj.info);
myObj.callExternalDLL(doIt);
showmessage(myObj.info);
end;
procedure TForm1.Button2Click(Sender: TObject);
var
msg:longword;
begin
msg:=WM_MYMSG;
myObj.Dispatch(msg);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
myObj :=TMyObject.Create;
myObj.age :=24
myObj.name :='savenight';
end;