How to trigger the event together on each two deferent class.
- by XBasic3000
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;