Registriert seit: 10. Aug 2005
33 Beiträge
Delphi 6 Enterprise
|
Re: class(TPersistent) - Zugriff auf "höhere" Proz
20. Aug 2005, 17:59
1. DANKE an alle die mir geholfen haben
2. Ich hab es jetzt geschafft.
Delphi-Quellcode:
unit TestOwner;
interface
uses
Windows, Messages, SysUtils, Classes, Controls, ExtCtrls;
type
TUnter = class(TPersistent)
private
FZahl : Integer;
FOnChange : TNotifyEvent;
procedure SetZahl( const Value: Integer);
protected
procedure Change; virtual;
published
property OnChange: TNotifyEvent read FOnChange write FOnChange;
property Zahl : Integer read FZahl write SetZahl;
end;
type
TTestOwner = class(TPaintbox)
private
{ Private declarations }
FMain : TUnter;
protected
{ Protected declarations }
public
{ Public declarations }
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure Upgrade(Sender: TObject);
published
{ Published declarations }
property Main : TUnter read FMain write FMain;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents(' My Own', [TTestOwner]);
end;
{ TTestOwner }
constructor TTestOwner.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FMain := TUnter.Create;
FMain.OnChange := Upgrade;
end;
destructor TTestOwner.Destroy;
begin
FMain.Free;
inherited Destroy;
end;
procedure TTestOwner.Upgrade(Sender: TObject);
begin
Self.Canvas.TextOut(Self.FMain.FZahl,1,' Hallo');
end;
{ TUnter }
procedure TUnter.Change;
begin
if Assigned(FOnChange) then
FOnChange(Self);
end;
procedure TUnter.SetZahl( const Value: Integer);
begin
FZahl := Value;
Change;
end;
end.
Use the Source, Luke.
|
|
Zitat
|