小弟刚开始学开发组件,帮忙看一下,怎么控件上没有显示caption
unit btn;interfaceuses
SysUtils, Classes, Controls,dialogs,windows,forms,extctrls,messages,graphics;type
tbtn = class(TCustomControl)
private
fbordercolor: tcolor;
fform:tform;
ffont:tfont; fcaption: tcaption;
procedure setbordercolor(Value: tcolor);
procedure setfont(Value: tfont);
procedure setcaption(const Value: tcaption);
{ Private declarations }
protected
{ Protected declarations } public
{ Public declarations }
procedure paint;override;
constructor create(aowner:tcomponent);override;
published
{ Published declarations }
property width;
property caption:tcaption read fcaption write setcaption;
property ondblclick;
property font:tfont read ffont write setfont;
property bordercolor:tcolor read fbordercolor write setbordercolor;
end;procedure Register;
var
editrect:trect;
implementationprocedure Register;
begin
RegisterComponents('haoge', [tbtn]);
end;{ tbtn }constructor tbtn.create(aowner: tcomponent);
begin
inherited create (aowner);
fform:=tform(owner);
ffont:=tfont.Create();
end;procedure tbtn.paint;
var r:trect;
textl,textt:integer;
begin
r:=clientrect;
frame3d(canvas,r,fbordercolor,fbordercolor,1);
inherited;
end;procedure tbtn.setbordercolor(Value: tcolor);
begin
fbordercolor := Value;
repaint;
end;procedure tbtn.setcaption(const Value: tcaption);
begin
fcaption := Value;
end;procedure tbtn.setfont(Value: tfont);
begin
ffont := Value;
end;end.
unit btn;interfaceuses
SysUtils, Classes, Controls,dialogs,windows,forms,extctrls,messages,graphics;type
tbtn = class(TCustomControl)
private
fbordercolor: tcolor;
fform:tform;
ffont:tfont; fcaption: tcaption;
procedure setbordercolor(Value: tcolor);
procedure setfont(Value: tfont);
procedure setcaption(const Value: tcaption);
{ Private declarations }
protected
{ Protected declarations } public
{ Public declarations }
procedure paint;override;
constructor create(aowner:tcomponent);override;
published
{ Published declarations }
property width;
property caption:tcaption read fcaption write setcaption;
property ondblclick;
property font:tfont read ffont write setfont;
property bordercolor:tcolor read fbordercolor write setbordercolor;
end;procedure Register;
var
editrect:trect;
implementationprocedure Register;
begin
RegisterComponents('haoge', [tbtn]);
end;{ tbtn }constructor tbtn.create(aowner: tcomponent);
begin
inherited create (aowner);
fform:=tform(owner);
ffont:=tfont.Create();
end;procedure tbtn.paint;
var r:trect;
textl,textt:integer;
begin
r:=clientrect;
frame3d(canvas,r,fbordercolor,fbordercolor,1);
inherited;
end;procedure tbtn.setbordercolor(Value: tcolor);
begin
fbordercolor := Value;
repaint;
end;procedure tbtn.setcaption(const Value: tcaption);
begin
fcaption := Value;
end;procedure tbtn.setfont(Value: tfont);
begin
ffont := Value;
end;end.
procedure tbtn.setcaption(const Value: tcaption);
begin
fcaption := Value;
Invalidatel;
end;