Einzelnen Beitrag anzeigen

sebi87
(Gast)

n/a Beiträge
 
#1

Problem mit Property

  Alt 23. Apr 2008, 08:41
Hallo Leute ich hab volgenden Quellcode:

Delphi-Quellcode:
unit Ball;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls;

type
  TMyPoint = class(TPersistent)
  Private
    fx, fy : integer ;
  Published
    constructor Create ;
    property x: integer read fx write fx;
    property y: integer read fy write fy;
  end;

  TBall= class(TComponent)
  private
    FMittelpunkt : TPoint ;
    BMittelpunkt : TMyPoint ;
    FImage : TImage ;
    FFont : TFont ;
    { Private-Deklarationen }
  protected
    { Protected-Deklarationen }
  public
    constructor Create(AOwner : TComponent) ;
    destructor Destroy ;
    procedure GetPoint(Y : integer) ;
    { Public-Deklarationen }
  published
    property MittelpunktLeft : integer read FMittelpunkt.x write FMittelpunkt.x ;
    property MittelpunktHight : integer read FMittelpunkt.y write FMittelpunkt.y ;
    property Mittelpunkt : TMyPoint read BMittelpunkt write BMittelpunkt ;
    property PaintPlane : TImage read FImage write FImage ;
    property Font: TFont read FFont write FFont;
    { Published-Deklarationen }
  end;

procedure Register;

implementation

constructor TMyPoint.Create ;
begin
  fy := 0 ;
  fx := 0 ;
end ;

procedure Register;
begin
  RegisterComponents('Kugel', [TBall]);
end;


constructor TBall.Create(AOwner: TComponent);
begin
  inherited Create(AOwner) ;
  BMittelpunkt := TMyPoint.Create ;
  FMittelpunkt.y := 0 ;
  PaintPlane := nil ;
  FFont := TFont.Create;
end;

destructor TBall.Destroy ;
begin
  BMittelpunkt.Free ;
  FFont.Free ;
  inherited Destroy ;
end ;

procedure TBall.GetPoint(Y : integer) ;
begin
  FMittelpunkt.y := Y ;
end ;

end.
Wenn ich jetzt im OI auf die property Font zugreifen will erscheint jedes mal die Fehlermeldung
Zitat:
Zugriffsverletzung bei Adresse 400039709 in Modul 'Vcl40.bpl'. Lesen von Adresse 00000000
Wie kann ich das beheben?

Sebastian
  Mit Zitat antworten Zitat