Deine Zeichenroutine gehört nicht ins Create, sondern ins Paint der Komponente. Dazu musst du die Paint Methode überschreiben:
Delphi-Quellcode:
unit DelphiPaxisTest;
interface
uses
System.SysUtils, System.Classes,
Vcl.Controls,
Vcl.ExtCtrls,
Vcl.Graphics;
type
TDelphiPaxisTest =
class(TImage)
private
{ Private-Deklarationen }
protected
{ Protected-Deklarationen }
procedure Paint;
override;
public
{ Public-Deklarationen }
constructor Create(AOwner: TComponent);
override;
destructor Destroy;
override;
published
{ Published-Deklarationen }
end;
procedure Register;
implementation
constructor TDelphiPaxisTest.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
end;
destructor TDelphiPaxisTest.Destroy;
begin
inherited;
end;
procedure TDelphiPaxisTest.Paint;
begin
inherited;
if csDesigning
in ComponentState
then
begin
Canvas.Pen.Color := clGray;
Canvas.Brush.Color:= clWhite;
Canvas.Brush.Style:= bsSolid;
Canvas.Rectangle(0, 0, Width, Height);
end
else
begin
//passt schon
end;
end;
procedure Register;
begin
RegisterComponents('
Samples', [TDelphiPaxisTest]);
end;
end.