Einzelnen Beitrag anzeigen

torud

Registriert seit: 26. Jul 2002
Ort: Sachsen
1.198 Beiträge
 
Delphi XE5 Professional
 
#2

Re: Benötige Hilfe beim Entwickeln einer Komponente

  Alt 29. Aug 2007, 06:37
Ich habe die Komponente jetzt dahingehend geändert, dass ich SetColor entfernt habe und OnPaint eingefügt habe. Leider bringt das gar nix, da die procedure scheinbar NIE aufgerufen oder ausgelöst wird. Warum nur?

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 OnPaint;
    { 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.OnPaint;
begin
    Canvas.Brush.Color := FBgColorFrom;
    Canvas.TextOut(1,1,'Test');
    Canvas.Refresh;
end;

end.
Danke
Tom
  Mit Zitat antworten Zitat