事件无法覆盖,但可以屏掉父类的事件,声明一个新的同名事件
TXXXServer = class(TServerSocket)
private
FOnGetThread:TGetThreadEvent;
procedure iGetThread(Sender: TObject; ClientSocket: TServerClientWinSocket; var SocketThread: TServerClientThread);
published
property OnGetThread:TGetThreadEvent read FOnGetThread write FOnGetThread;
...
end;
constructor TXXXServer.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
inherited OnGetThread = iGetThread;
end;
procedure TXXXServer.iGetThread(Sender: TObject; ClientSocket: TServerClientWinSocket; var SocketThread: TServerClientThread);
begin
....//你的代码
if Assigned(FOnGetThread) then
FOnGetThread(Sender,ClientSocket,SocketThread);
end;
其实编写合理的组件一般会写一个DoXXXX的虚方法,这样就不需要这么麻烦的屏蔽父类的事件.只需要覆盖DoXXXX方法就行了,你可以多看看源码,从中看看是否是这样,
DoXXXX(....);
if Assigned(FOnXXXX) then
FOnXXX(,...)