Einzelnen Beitrag anzeigen

Benutzerbild von Bernhard Geyer
Bernhard Geyer

Registriert seit: 13. Aug 2002
17.171 Beiträge
 
Delphi 10.4 Sydney
 
#12

Re: Problem mit Vererbung auf Frames

  Alt 2. Dez 2008, 21:19
Gut das du lernen willst. Hier mal die Basisunit umgebaut (soweit ich verstanden habe was du eigentlich machen willst):

Delphi-Quellcode:
// Kein Uses mehr auf Hauptunit nötig! Enge kopplung und gegenseitige Referenzierung der Units damit gelöst

type
  TMyCallBack = function(Sender: TObject; const Inhalt, Code: String): String;

  TFrame3 = class(TFrame)
  private
    FMyCallBack: TMyCallBack;
  public
    function Ausgabe(const Inhalt, Code: String): String;

    property MyCallBack: TMyCallBack read FMyCallBack write FMyCallBack;
  end;

implementation

function Tframe3.Ausgabe(const Inhalt, Code: String): String;
begin
  if Assigned(FMyCallBack) then
    result := FMyCallBack(self, Inhalt, Code)
  else
    result := '';
end;
und in der Hauptunit:

Delphi-Quellcode:
uses
  frames;

procedure TForm1.OnCreate;
begin
  FMyFrame := TFrame2.Create(self);
  ...
  FMyFrame.OnMyCallBack := DoMyCallBack;
end;

function TForm1.DoMyCallBack(Sender: TObject; const Inhalt, Code: String): String;
begin
  Inhalt.Text:=Inhalt;
  Code.Text:=Inhalt;
  Frame11.Findekomponente.Click;
end;
Windows Vista - Eine neue Erfahrung in Fehlern.
  Mit Zitat antworten Zitat