How to trigger the event together on each two deferent class.

Posted by XBasic3000 on Stack Overflow See other posts from Stack Overflow or by XBasic3000
Published on 2010-05-31T02:22:29Z Indexed on 2010/05/31 6:22 UTC
Read the original article Hit count: 287

I have two object class on a single unit, is it posible to trigger the two events? let say the FIRSTCLASS event is fired, The SECONDCLASS also will fired?

Assuming......

//{Class 1}-------------------------------------------------------------
type
   TOnEventTrigger = procedure(Sender : Tobject; Value :integer); 
   TMyFirstClass = Class(Tcomponent)
   private
      ....
   public
      ....
      OnEventTrigger : TOnEventTrigger read Fevent write Fevent;
   end;

procedure TMyFirstClass.FEvnt(Sender : Tobject; Value :integer); 
begin
    // here is normaly triggers the event //
    if Assigned(OnEventTrigger) then
       OnEventTrigger(Self,FSomevalue);

    // POSTMessage(GetForegroundWindow,WM_USER+3,0,0);
    // this is what i did here to get the result of FSomevalue
    // but this is not ideal. It work only on focus window.

end;

//{Class 2}-------------------------------------------------------------

type
   TOnEventTrigger = procedure(Sender : Tobject; Value :integer); 
   TMySecondClass = Class(Tobject)
   private
      ....
   public
      ....
      OnEventTrigger : TOnEventTrigger; read Fevent write Fevent;
   end;

procedure TMySecondClass.FEvnt(Sender : Tobject; Value :integer); 
begin
    // I wanted here to trigger, whenenver the above is fired //
    if Assigned(OnEventTrigger) then
       OnEventTrigger(Self,FSomevalue);
end;

© Stack Overflow or respective owner

Related posts about delphi

Related posts about delphi-2009