Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   GUI-Design mit VCL / FireMonkey / Common Controls (https://www.delphipraxis.net/18-gui-design-mit-vcl-firemonkey-common-controls/)
-   -   Delphi Bitmap Property (https://www.delphipraxis.net/52370-bitmap-property.html)

TheSaint 29. Aug 2005 08:32


Bitmap Property
 
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


Alle Zeitangaben in WEZ +1. Es ist jetzt 05:27 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz