Z
zj_cat
Unregistered / Unconfirmed
GUEST, unregistred user!
我想创建一个控件,其主要要求如下:
1 有一个Label和一个Shape组成;
2 Shape是一个stCircle;
3 Label位于Shape上方,叠在一起,底色为Shape的颜色 ;
4 可根据鼠标的动作变换颜色;
5 可获得焦点,有TabOrder值
6 Label的Caption在实例被创建时,自动生成为该控件的TabOrder值
我看书写了一个最基本的代码,我觉得好像没有什么地方不对,最少可以
显示一个样子,却不被机器认可,总是出错,为表示感谢,提供100分
unit Tube;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics,
Controls, Forms, Dialogs,stdCtrls,ExtCtrls;
type
TTube = class(TCustomControl)
private
FLbl:TLabel;
FShape:Tshape;
{ Procedure ChangeColor(Const Value: TColor ); 暂未实现}
protected
public
constructor Create(AOwner:Tcomponent);override;
published
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('MyTube', [TTube]);
end;
{ TTube }
constructor TTube.Create(AOwner: Tcomponent);
begin
inherited Create(AOwner);
Width:=18;
Height:=18;
FShape.Create(Self);
FShape.Parent:=self;
FShape.Brush.Color:=clBlue;
FShape.Pen.Color:=clNone;
FShape.Pen.Mode:=pmCopy;
FShape.Height:=18;
FShape.Width:=18;
FShape.Visible:=True;
FShape.Shape:=stCircle;
FShape.Top:=0;
FShape.Left:=0;
FLbl:=TLabel.Create(self);
FLbl.Parent:=Self;
FLbl.Font.Name:='宋体';
Flbl.Font.Color:=clRed;
FLbl.Font.Size:=16;
FLbl.Caption:=TRim(inttostr(AOwner.Tag));
FLbl.Color:=clBlue;
FLbl.Alignment:=taCenter;
FLbl.Height:=18;
FLbl.Width:=18;
FLbl.Top:=0;
FLbl.Left:=0;
FLbl.Visible:=True;
end;
end.
1 有一个Label和一个Shape组成;
2 Shape是一个stCircle;
3 Label位于Shape上方,叠在一起,底色为Shape的颜色 ;
4 可根据鼠标的动作变换颜色;
5 可获得焦点,有TabOrder值
6 Label的Caption在实例被创建时,自动生成为该控件的TabOrder值
我看书写了一个最基本的代码,我觉得好像没有什么地方不对,最少可以
显示一个样子,却不被机器认可,总是出错,为表示感谢,提供100分
unit Tube;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics,
Controls, Forms, Dialogs,stdCtrls,ExtCtrls;
type
TTube = class(TCustomControl)
private
FLbl:TLabel;
FShape:Tshape;
{ Procedure ChangeColor(Const Value: TColor ); 暂未实现}
protected
public
constructor Create(AOwner:Tcomponent);override;
published
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('MyTube', [TTube]);
end;
{ TTube }
constructor TTube.Create(AOwner: Tcomponent);
begin
inherited Create(AOwner);
Width:=18;
Height:=18;
FShape.Create(Self);
FShape.Parent:=self;
FShape.Brush.Color:=clBlue;
FShape.Pen.Color:=clNone;
FShape.Pen.Mode:=pmCopy;
FShape.Height:=18;
FShape.Width:=18;
FShape.Visible:=True;
FShape.Shape:=stCircle;
FShape.Top:=0;
FShape.Left:=0;
FLbl:=TLabel.Create(self);
FLbl.Parent:=Self;
FLbl.Font.Name:='宋体';
Flbl.Font.Color:=clRed;
FLbl.Font.Size:=16;
FLbl.Caption:=TRim(inttostr(AOwner.Tag));
FLbl.Color:=clBlue;
FLbl.Alignment:=taCenter;
FLbl.Height:=18;
FLbl.Width:=18;
FLbl.Top:=0;
FLbl.Left:=0;
FLbl.Visible:=True;
end;
end.