Thema: Delphi Objekt Kommunikation

Einzelnen Beitrag anzeigen

fajac

Registriert seit: 1. Jul 2009
60 Beiträge
 
#2

Re: Objekt Kommunikation

  Alt 2. Jul 2009, 12:08
Ein Event ist die Lösung. z.B.

Delphi-Quellcode:
type
  TObjectData = class
  private
    FNotify : TNotifyEvent;
  public
    property OnNotify : TNotifyEvent read FNotify write FNotify;
    procedure NotifyGUI;
  end;


implementation

procedure TObjectData.NotifyGUI;
begin
  if Assigned (FNotify) then
    FNotify (Self);
end;
und in UnitGUI:
Delphi-Quellcode:

type
  TObjectGUI = class
  private
    Data : TObjectData;
    procedure OnNotify (Sender : TObject);
  public
    Constructor Create;
  end;

implementation

constructor TObjectGUI.Create;
begin
  Data := TObjectData.Create;
  Data.OnNotify := OnNotify;
end;

procedure OnNotify (Sender : TObject);
begin
  { Wird aufgerufen wenn in TObjectData NotifyGUI durchlaufen wird. }
end;
  Mit Zitat antworten Zitat