主题:自定义控件画边缘色的问题
帮我看看有什么问题,为什么画出来的按钮边缘色不全?????
unit XPButton;
interface
uses
SysUtils, Classes, Controls, StdCtrls,Graphics,windows,forms,messages,
extctrls;
type
TXPButton = class(TButton)
private
FColor: TColor;
PanelCanvas:TCanvas;
procedure SetColor(const Value: TColor);
{ Private declarations }
protected
{ Protected declarations }
public
{ Public declarations }
constructor create(AOwner:TComponent);override;
published
{ Published declarations }
property BordorColor:TColor read FColor write SetColor;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('haoge', [TXPButton]);
end;
{ TXPButton }
constructor TXPButton.create(AOwner: TComponent);
begin
inherited create(AOwner);
end;
procedure TXPButton.SetColor(const Value: TColor);
var r:TRect;
begin
r:=ClientRect;
FColor := Value;
PanelCanvas :=TControlCanvas.Create;
TControlCanvas(PanelCanvas).Control:=self;
PanelCanvas.Pen.Color:=FColor;
PanelCanvas.Brush.Style:=bsClear;
PanelCanvas.Rectangle(0,0,width,height);
PanelCanvas.Free;
end;
end.
unit XPButton;
interface
uses
SysUtils, Classes, Controls, StdCtrls,Graphics,windows,forms,messages,
extctrls;
type
TXPButton = class(TButton)
private
FColor: TColor;
PanelCanvas:TCanvas;
procedure SetColor(const Value: TColor);
{ Private declarations }
protected
{ Protected declarations }
public
{ Public declarations }
constructor create(AOwner:TComponent);override;
published
{ Published declarations }
property BordorColor:TColor read FColor write SetColor;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('haoge', [TXPButton]);
end;
{ TXPButton }
constructor TXPButton.create(AOwner: TComponent);
begin
inherited create(AOwner);
end;
procedure TXPButton.SetColor(const Value: TColor);
var r:TRect;
begin
r:=ClientRect;
FColor := Value;
PanelCanvas :=TControlCanvas.Create;
TControlCanvas(PanelCanvas).Control:=self;
PanelCanvas.Pen.Color:=FColor;
PanelCanvas.Brush.Style:=bsClear;
PanelCanvas.Rectangle(0,0,width,height);
PanelCanvas.Free;
end;
end.