我想创建一个类,从SPComm控件里申明的Tcomm继承,
   TReadCardComm=class(TComm)
   但不知该如何捕获里面的
ReceiveData(Sender: TObject; Buffer: Pointer;BufferLength: Word);事件,你有什么办法吗?
    谢谢指导

解决方案 »

  1.   

    你从它继承了,自然也就继承了父类的方法
    create时
    inherited Create(AOwner);
      

  2.   

    例子:
     从TButton继承一个新的TMyButton
    我要在TButton Onclick的时候做手脚找到property OnClick: TNotifyEvent read FOnClick write FOnClick stored IsOnClickStored;在源代码中查找何处触发OnClick(搜索FOnclick)
    procedure TControl.Click;
    begin
      { Call OnClick if assigned and not equal to associated action's OnExecute.
        If associated action's OnExecute assigned then call it, otherwise, call
        OnClick. }
      if Assigned(FOnClick) and (Action <> nil) and (@FOnClick <> @Action.OnExecute) then
        FOnClick(Self)
      else if not (csDesigning in ComponentState) and (ActionLink <> nil) then
        ActionLink.Execute
      else if Assigned(FOnClick) then
        FOnClick(Self);
    end;因此,只需要重载Click在调用FOnClick(Self)之前或者之后插入自己要的代码就OK
      

  3.   

    这是事件呀,不是方法,是event,如果可以,我ReceiveData的代码要写在哪里,原来的SPComm的OnReceiveData的事件里可以写代码,但我继承以后要怎么写呢?
      

  4.   

    继承以后还是在OnReceiveData事件里写代码阿你可以写一个
    myProcedure(Sender: TObject; Buffer: Pointer;BufferLength: Word);然后xxxx.OnReceiveData := myProcedure;
      

  5.   

    procedure TControl.Click;
    begin
      { Call OnClick if assigned and not equal to associated action's OnExecute.
        If associated action's OnExecute assigned then call it, otherwise, call
        OnClick. }
      if Assigned(FOnClick) and (Action <> nil) and (@FOnClick <> @Action.OnExecute) then
        FOnClick(Self)
      else if not (csDesigning in ComponentState) and (ActionLink <> nil) then
        ActionLink.Execute
      else if Assigned(FOnClick) then
        FOnClick(Self);
    end;
    //这段代码是什么意思呀,看到的人谁能解释一下呀吗?我就是楼主,这是一位朋友给我的答案,但我看不懂。拜托拉
      

  6.   

    英文解释就是:
    调用onclick事件在以下情况:
    1.onclick定义,而且不是action事件
    2.是action事件,并且onexecute定义
    3.其他
    然后代码就是判断这些