Thema: Delphi Bitmap Property

Einzelnen Beitrag anzeigen

TheSaint

Registriert seit: 29. Aug 2005
18 Beiträge
 
#1

Bitmap Property

  Alt 29. Aug 2005, 08:32
Hallo!
ich habe eine published Bitmap-Property in meiner Komponente. Ich kann auch der Eigenschaft im Objektinspektor ein Bitmap zuweisen.
Bei Start der Anwendung bekomme ich jedoch einen eReadError.
Hat jemand eine Ahnung woran dies liegt?
Hier mein Code:
Delphi-Quellcode:
unit TestButton;

interface

uses
  Windows, Messages, SysUtils, Classes, Controls, StdCtrls, graphics,Dialogs;

type
  TTestButton = class(TButton)
  private
     private fGlyph: TBitmap;
     procedure SetGlyph(bmp:TBitmap);
     function GetGlyph:TBitmap;
    { Private-Deklarationen }
  protected
    { Protected-Deklarationen }
  public
   constructor Create(AOwner: TComponent);
   destructor Destroy;
    { Public-Deklarationen }
  published
     property Glyph: TBitmap read GetGlyph write SetGlyph;
    { Published-Deklarationen }
  end;

procedure Register;

implementation

procedure Register;
begin
  RegisterComponents('Themed', [TTestButton]);
end;

{ TestButton }


constructor TTestButton.Create(AOwner: TComponent);
begin
 inherited Create(AOwner);
 fGlyph:=TBitmap.Create;
end;

destructor TTestButton.Destroy;
begin
 fGlyph.Free;
 fGlyph:=nil;
 inherited Destroy;
end;

function TTestButton.GetGlyph: TBitmap;
begin
 if fGlyph=nil then begin
   result:=nil;
   exit;
 end;
 result:=TBitmap.Create;
 result.Assign(fGlyph);
end;

procedure TTestButton.SetGlyph(bmp: TBitmap);
begin
 if fGlyph=nil then
    fGlyph:=TBitmap.Create;
 fGlyph.Assign(bmp);
end;

end.
MfG
TheSaint
  Mit Zitat antworten Zitat