Ok, ich habe es nun so wie von Dir empfohlen geändert, aber jetzt ist leider kein Zeichnen auf Leinwand mehr erlaubt...Scheinbar doch nicht alles so einfach, wie erwartet. Ein Buch ist bestellt, aber trotzdem will ich nicht warten
hier nochmal der gesamte Code:
Delphi-Quellcode:
unit myPanel;
interface
uses
Windows, Messages, SysUtils, Classes, Controls, Graphics;
type
TbdStyle = (bdSolid, bdDashed, bdClear, bdDotted);
TGdDirection = (gdHorizontal, gdVertical, gdDiagonal);
type
TmyPanel =
class(TCustomControl)
private
Canvas : TCanvas;
FBgColorFrom : TColor;
FBgColorTo : TColor;
FPaintGradient : Boolean;
FGradientDirection : TGdDirection;
FBorderColor:TColor;
FBorderStyle:TbdStyle;
FBorderWidth:integer;
FRoundEdges:boolean;
FCornerWidth:integer;
{ Private-Deklarationen }
public
constructor Create(AOwner: TComponent);
override;
destructor Destroy;
override;
{ Public-Deklarationen }
published
property BgColorFrom : TColor
read FBgColorFrom
write FBgColorFrom;
property BgColorTo : TColor
read FBgColorTo
write FBgColorTo;
property PaintGradient : boolean
read FPaintGradient
write FPaintGradient;
property GradientDirection : TGdDirection
read FGradientDirection
write FGradientDirection;
property BorderColor : TColor
read FBorderColor
write FBorderColor;
property BorderStyle : TbdStyle
read FBorderStyle
write FBorderStyle;
property BorderWidth : integer
read FBorderWidth
write FBorderWidth;
property RoundEdges : boolean
read FRoundEdges
write FRoundEdges;
property CornerWidth : integer
read FCornerWidth
write FCornerWidth;
procedure Paint;
override;
{ Published-Deklarationen }
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('
Standard', [TmyPanel]);
end;
constructor TmyPanel.Create(AOwner: TComponent);
begin
Canvas := TCanvas.Create;
inherited Create(AOwner);
end;
destructor TmyPanel.Destroy;
begin
inherited;
Canvas.Free;
end;
procedure TmyPanel.Paint;
begin
Canvas.Brush.Color := FBgColorFrom;
Canvas.TextOut(1,1,'
Test');
end;
end.