R
rmichael
Unregistered / Unconfirmed
GUEST, unregistred user!
[]现有一ActiveForm,其中有自定义事件
type
TGpsLocateEvent=procedure(Sender:TObject;wParam:integer;lParam:string) of object;
...
public
GpsLocateEvent :TGpsLocateEvent;
...
published
property OnGpsLocate:TGpsLocateEvent read GpsLocateEvent write GpsLocateEvent;
...
在type library为此控件添加了OnGpsLocate事件接口,并且通过TButton.OnClick来激活该事件
procedure TAFX_GpsLocate.B_LocateClick(Sender: TObject);
var
id:integer;
context:string;
begin
id:=1;
context:='adfasd';
if assigned(GpsLocateEvent) then
GpsLocateEvent(self,id,context);
end;
在此控件的测试程序中,添加了事件处理
procedure TForm1.AFX_GpsLocate1GpsLocate(Sender: TObject;
var wParam: Integer; var lParam: WideString);
begin
showmessage(format('wParam:%d'+chr(13)+'lParam:%s',[wparam,lparam]));
end;
请问为什么assigned(GpsLocateEvent)为false?如何将自定义事件与其接口对应连接?
type
TGpsLocateEvent=procedure(Sender:TObject;wParam:integer;lParam:string) of object;
...
public
GpsLocateEvent :TGpsLocateEvent;
...
published
property OnGpsLocate:TGpsLocateEvent read GpsLocateEvent write GpsLocateEvent;
...
在type library为此控件添加了OnGpsLocate事件接口,并且通过TButton.OnClick来激活该事件
procedure TAFX_GpsLocate.B_LocateClick(Sender: TObject);
var
id:integer;
context:string;
begin
id:=1;
context:='adfasd';
if assigned(GpsLocateEvent) then
GpsLocateEvent(self,id,context);
end;
在此控件的测试程序中,添加了事件处理
procedure TForm1.AFX_GpsLocate1GpsLocate(Sender: TObject;
var wParam: Integer; var lParam: WideString);
begin
showmessage(format('wParam:%d'+chr(13)+'lParam:%s',[wparam,lparam]));
end;
请问为什么assigned(GpsLocateEvent)为false?如何将自定义事件与其接口对应连接?