unit KtvButton;
interface
uses
SysUtils, Classes, Controls, StdCtrls, Messages,ExtCtrls,
Graphics;
type
//TKtvButton = class(TWinControl)
TKtvButton = class(TPanel) //ExtCtrls;
private
FPanel: TPanel;
FTime: TTimer;
FLabel1: TLabel;
FLabel2: TLabel;
FLabel3: TLabel;
FLabel4: TLabel;
FLabel5: TLabel;
FLabel6: TLabel;
FLabel7: TLabel;
// FEdit: TEdit;
// FButton: TButton;
// FText: string;
FCaption: string;
FColor: TColor; //颜色
FColorSD: TColor; //闪动的颜色
FSd:Boolean;
function GetCaption: string;
procedure FSetCaption(AValue: string);
procedure FSetCaption2(AValue: string);
procedure FSetCaption3(AValue: string);
procedure FSetCaption4(AValue: string);
procedure FSetCaption5(AValue: string);
procedure FSetCaption6(AValue: string);
procedure FSetCaption7(AValue: string); function GetOnClick: TnotifyEvent;//读单击
function GetOnDbClick: TnotifyEvent;//读双击
procedure SetOnClick(AValue: TnotifyEvent);//设单击
procedure SetOnDbClick(AValue: TnotifyEvent);//设双击// procedure OnEditChange(Sender: TObject);
procedure FTimerTimer(Sender:Tobject);//时间控件的事件处理函数
procedure SetSd(A:boolean);
function FGetColorBZ: TColor;
procedure FSetColorBZ(CValue:TColor);
function FGetColorFM: TColor;
procedure FSetColorFM(CValue:TColor);
procedure FSetColorFX(CValue:TColor);
procedure FSetColorRS(CValue:TColor);
procedure FSetColorT1(CValue:TColor);
procedure FSetColorT2(CValue:TColor);
procedure FSetColorSD(CValue:TColor);
protected
procedure WMSize(var Msg: TMessage);message WM_SIZE;
public
constructor Create(AOwner: TComponent);override;
destructor Destroy;override;
procedure stop;//停止闪动
procedure start;//开始闪动
published
// property Text: string read FText write FSetText;
property Caption: string read GetCaption write FSetCaption;
property CaptionLX: string read FCaption write FSetCaption2;
property CaptionRS: string read FCaption write FSetCaption3;
property CaptionKS: string read FCaption write FSetCaption4;
property CaptionJS: string read FCaption write FSetCaption5;
property CaptionKJ: string read FCaption write FSetCaption6;
property CaptionGJ: string read FCaption write FSetCaption7;
property Sd:boolean read FSd write SetSd default false; //边框是否闪动
property ColorBZ:TColor read FGetColorBZ write FSetColorBZ;
property ColorFM:TColor read FGetColorFM write FSetColorFM;
property ColorFX:TColor read FColor write FSetColorFX;
property ColorRS:TColor read FColor write FSetColorRS;
property ColorT1:TColor read FColor write FSetColorT1;
property ColorT2:TColor read FColor write FSetColorT2;
property ColorSD:TColor read FColorSD write FSetColorSD;//闪动的颜色
property Font;
property OnClick:TnotifyEvent read GetOnClick write SetOnClick;//单击组件
property OnDblClick:TnotifyEvent read GetOnDbClick write SetOnDbClick;//双击组件
property color;
//property OnDblClick;
// property BorderStyle;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Linco', [TKtvButton]);
end;
constructor TKtvButton.Create(AOwner: TComponent);
begin
inherited;
// inherited Create(AOwner); Height:=86;
Width:=98; FPanel := TPanel.Create(self);
FPanel.Parent := self;
FPanel.Top:= 20;
FPanel.Left := 20;
FPanel.Height:=Height - 40;
FPanel.Width:= Width - 40; FTime := TTimer.Create(nil);
FTime.Interval:=500;
FTime.Enabled:=false;
FTime.OnTimer:=FTimerTimer;
FLabel6:= TLabel.Create(nil);
FLabel6.Parent := FPanel;
FLabel7:= TLabel.Create(nil);
FLabel7.Parent := FPanel;
FLabel1:= TLabel.Create(nil);
FLabel1.Parent := FPanel;
FLabel2:= TLabel.Create(nil);
FLabel2.Parent := FPanel;
FLabel3:= TLabel.Create(nil);
FLabel3.Parent := FPanel;
FLabel4:= TLabel.Create(nil);
FLabel4.Parent := FPanel;
FLabel5:= TLabel.Create(nil);
FLabel5.Parent := FPanel;end;
destructor TKtvButton.Destroy;
begin
FTime.Free;
// FEdit.Free;
FLabel1.Free;
FLabel2.Free;
FLabel3.Free;
FLabel4.Free;
FLabel5.Free;
FLabel6.Free;
FLabel7.Free;
// FButton.Free;
FPanel.Free;
inherited;
end;function TKtvButton.GetCaption: string;
begin
result := FLabel1.Caption;
end;function TKtvButton.FGetColorBZ: TColor; //返回主体颜色
begin
result := FPanel.Color ;//颜色
end;function TKtvButton.FGetColorFM: TColor; //返回颜色
begin
result := FLabel1.Font.Color ;//颜色
end;procedure TKtvButton.FSetCaption(AValue: string);
begin
FLabel1.Caption := AValue;
end;procedure TKtvButton.FSetCaption2(AValue: string);
begin
FLabel2.Caption := AValue;
end; procedure TKtvButton.FSetCaption3(AValue: string);
begin
FLabel3.Caption := AValue;
end;procedure TKtvButton.FSetCaption4(AValue: string);
begin
FLabel4.Caption := AValue;
if Length(FLabel4.Caption)>10 then //长度超过11缩小1号字体
FLabel4.Font.Size:=Font.Size-Length(FLabel4.Caption)+10
else
FLabel4.Font.Size:=Font.Size;
end;procedure TKtvButton.FSetCaption5(AValue: string);
begin
FLabel5.Caption := AValue;
if Length(FLabel5.Caption)>10 then //长度超过11缩小1号字体
FLabel5.Font.Size:=Font.Size-Length(FLabel5.Caption)+10
else
FLabel5.Font.Size:=Font.Size;
end;procedure TKtvButton.FSetCaption6(AValue: string);
begin
FLabel6.Caption := AValue;
end;procedure TKtvButton.FSetCaption7(AValue: string);
begin
FLabel7.Caption := AValue;
end;{
procedure TEditButton.OnEditChange(Sender: TObject);
begin
FButton.Caption := IntToStr(Length(FEdit.Text));
end;
}
interface
uses
SysUtils, Classes, Controls, StdCtrls, Messages,ExtCtrls,
Graphics;
type
//TKtvButton = class(TWinControl)
TKtvButton = class(TPanel) //ExtCtrls;
private
FPanel: TPanel;
FTime: TTimer;
FLabel1: TLabel;
FLabel2: TLabel;
FLabel3: TLabel;
FLabel4: TLabel;
FLabel5: TLabel;
FLabel6: TLabel;
FLabel7: TLabel;
// FEdit: TEdit;
// FButton: TButton;
// FText: string;
FCaption: string;
FColor: TColor; //颜色
FColorSD: TColor; //闪动的颜色
FSd:Boolean;
function GetCaption: string;
procedure FSetCaption(AValue: string);
procedure FSetCaption2(AValue: string);
procedure FSetCaption3(AValue: string);
procedure FSetCaption4(AValue: string);
procedure FSetCaption5(AValue: string);
procedure FSetCaption6(AValue: string);
procedure FSetCaption7(AValue: string); function GetOnClick: TnotifyEvent;//读单击
function GetOnDbClick: TnotifyEvent;//读双击
procedure SetOnClick(AValue: TnotifyEvent);//设单击
procedure SetOnDbClick(AValue: TnotifyEvent);//设双击// procedure OnEditChange(Sender: TObject);
procedure FTimerTimer(Sender:Tobject);//时间控件的事件处理函数
procedure SetSd(A:boolean);
function FGetColorBZ: TColor;
procedure FSetColorBZ(CValue:TColor);
function FGetColorFM: TColor;
procedure FSetColorFM(CValue:TColor);
procedure FSetColorFX(CValue:TColor);
procedure FSetColorRS(CValue:TColor);
procedure FSetColorT1(CValue:TColor);
procedure FSetColorT2(CValue:TColor);
procedure FSetColorSD(CValue:TColor);
protected
procedure WMSize(var Msg: TMessage);message WM_SIZE;
public
constructor Create(AOwner: TComponent);override;
destructor Destroy;override;
procedure stop;//停止闪动
procedure start;//开始闪动
published
// property Text: string read FText write FSetText;
property Caption: string read GetCaption write FSetCaption;
property CaptionLX: string read FCaption write FSetCaption2;
property CaptionRS: string read FCaption write FSetCaption3;
property CaptionKS: string read FCaption write FSetCaption4;
property CaptionJS: string read FCaption write FSetCaption5;
property CaptionKJ: string read FCaption write FSetCaption6;
property CaptionGJ: string read FCaption write FSetCaption7;
property Sd:boolean read FSd write SetSd default false; //边框是否闪动
property ColorBZ:TColor read FGetColorBZ write FSetColorBZ;
property ColorFM:TColor read FGetColorFM write FSetColorFM;
property ColorFX:TColor read FColor write FSetColorFX;
property ColorRS:TColor read FColor write FSetColorRS;
property ColorT1:TColor read FColor write FSetColorT1;
property ColorT2:TColor read FColor write FSetColorT2;
property ColorSD:TColor read FColorSD write FSetColorSD;//闪动的颜色
property Font;
property OnClick:TnotifyEvent read GetOnClick write SetOnClick;//单击组件
property OnDblClick:TnotifyEvent read GetOnDbClick write SetOnDbClick;//双击组件
property color;
//property OnDblClick;
// property BorderStyle;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Linco', [TKtvButton]);
end;
constructor TKtvButton.Create(AOwner: TComponent);
begin
inherited;
// inherited Create(AOwner); Height:=86;
Width:=98; FPanel := TPanel.Create(self);
FPanel.Parent := self;
FPanel.Top:= 20;
FPanel.Left := 20;
FPanel.Height:=Height - 40;
FPanel.Width:= Width - 40; FTime := TTimer.Create(nil);
FTime.Interval:=500;
FTime.Enabled:=false;
FTime.OnTimer:=FTimerTimer;
FLabel6:= TLabel.Create(nil);
FLabel6.Parent := FPanel;
FLabel7:= TLabel.Create(nil);
FLabel7.Parent := FPanel;
FLabel1:= TLabel.Create(nil);
FLabel1.Parent := FPanel;
FLabel2:= TLabel.Create(nil);
FLabel2.Parent := FPanel;
FLabel3:= TLabel.Create(nil);
FLabel3.Parent := FPanel;
FLabel4:= TLabel.Create(nil);
FLabel4.Parent := FPanel;
FLabel5:= TLabel.Create(nil);
FLabel5.Parent := FPanel;end;
destructor TKtvButton.Destroy;
begin
FTime.Free;
// FEdit.Free;
FLabel1.Free;
FLabel2.Free;
FLabel3.Free;
FLabel4.Free;
FLabel5.Free;
FLabel6.Free;
FLabel7.Free;
// FButton.Free;
FPanel.Free;
inherited;
end;function TKtvButton.GetCaption: string;
begin
result := FLabel1.Caption;
end;function TKtvButton.FGetColorBZ: TColor; //返回主体颜色
begin
result := FPanel.Color ;//颜色
end;function TKtvButton.FGetColorFM: TColor; //返回颜色
begin
result := FLabel1.Font.Color ;//颜色
end;procedure TKtvButton.FSetCaption(AValue: string);
begin
FLabel1.Caption := AValue;
end;procedure TKtvButton.FSetCaption2(AValue: string);
begin
FLabel2.Caption := AValue;
end; procedure TKtvButton.FSetCaption3(AValue: string);
begin
FLabel3.Caption := AValue;
end;procedure TKtvButton.FSetCaption4(AValue: string);
begin
FLabel4.Caption := AValue;
if Length(FLabel4.Caption)>10 then //长度超过11缩小1号字体
FLabel4.Font.Size:=Font.Size-Length(FLabel4.Caption)+10
else
FLabel4.Font.Size:=Font.Size;
end;procedure TKtvButton.FSetCaption5(AValue: string);
begin
FLabel5.Caption := AValue;
if Length(FLabel5.Caption)>10 then //长度超过11缩小1号字体
FLabel5.Font.Size:=Font.Size-Length(FLabel5.Caption)+10
else
FLabel5.Font.Size:=Font.Size;
end;procedure TKtvButton.FSetCaption6(AValue: string);
begin
FLabel6.Caption := AValue;
end;procedure TKtvButton.FSetCaption7(AValue: string);
begin
FLabel7.Caption := AValue;
end;{
procedure TEditButton.OnEditChange(Sender: TObject);
begin
FButton.Caption := IntToStr(Length(FEdit.Text));
end;
}
procedure TKtvButton.WMSize(var Msg: TMessage);
begin
BevelOuter:=bvLowered;
Color:=$c8d0d4; //底色
FPanel.Font.Name:='宋体';
ColorBZ:=$c8d0d4; //底色
ColorFM:=$000080; FPanel.Top:= 5;
FPanel.Left := 5;
FPanel.Height:=Height - 10;
FPanel.Width:= Width - 10;
FLabel1.Top:= 2;
//FLabel1.Left:= 2;
FLabel1.Alignment:=taCenter;//居中
FLabel1.Align:=alTop;//最上面
FLabel1.Font.Size:=Font.Size+4;
FLabel1.Font.Color:=$000080;//蓝绿红 R128
FLabel1.Font.Style:=[fsBold];//加粗 FLabel1.Caption:='名称';
FLabel1.AutoSize:=true;
FLabel2.Top:=FLabel1.Top+FLabel1.Height + 2;
FLabel2.Left:=2;
FLabel2.Font.Size:=Font.Size;
// FLabel2.Font.Color:=$0000ff;//蓝绿红
FLabel2.Caption:='Type';
FLabel2.AutoSize:=true;
FLabel3.Top:=FLabel2.Top;
FLabel3.Font.Size:=Font.Size;
// FLabel3.Font.Color:=$0000ff;//蓝绿红
FLabel3.Caption:='人';
FLabel3.AutoSize:=true;
FLabel3.Left:=FPanel.Width - FLabel3.Width -3;
FLabel4.Top:=FLabel3.Top+FLabel3.Height + 2;
FLabel4.Left:=2;
FLabel4.Font.Size:=Font.Size;
// FLabel4.Font.Color:=$0000ff;//蓝绿红
FLabel4.Caption:='时间';
FLabel4.AutoSize:=true;
FLabel6.Top:=FLabel4.Top;
FLabel6.Left:=FLabel4.Left+FLabel4.Width+12;
FLabel6.Font.Size:=Font.Size;
FLabel6.Font.Color:=$0000ff;//蓝绿红(红色)
FLabel6.Caption:='消';
FLabel6.AutoSize:=true;
FLabel5.Top:=FLabel4.Top+FLabel4.Height + 2;
FLabel5.Left:=2;
FLabel5.Font.Size:=Font.Size;
// FLabel5.Font.Color:=$0000ff;//蓝绿红
FLabel5.Caption:='时间';
FLabel5.AutoSize:=true;
FLabel7.Top:=FLabel5.Top;
FLabel7.Left:=FLabel5.Left+FLabel5.Width+12;
FLabel7.Font.Size:=Font.Size;
FLabel7.Font.Color:=$0000ff;//蓝绿红(红色)
FLabel7.Caption:='关';
FLabel7.AutoSize:=true;end;procedure TKtvButton.FTimerTimer(Sender:TObject);begin if Color<>$c8d0d4 then //$0000ff then
begin
Color:=$c8d0d4; //底色
end
else
begin
Color:=FColorSD; //$0000ff; //红色
end;end;
procedure TKtvButton.stop;
begin
FTime.Enabled:=False;
Color:=$c8d0d4; //底色
end;procedure TKtvButton.start;begin FTime.Enabled:=true;end;procedure TKtvButton.SetSd(A:boolean);
begin if A then
FTime.Enabled:=true
else
begin
FTime.Enabled:=False;
Color:=$c8d0d4; //底色
// FLabel1.Font.Color:=$0000ff;
end;end;function TKtvButton.GetOnClick: TnotifyEvent;
begin
result := FPanel.Onclick;//单击
end;function TKtvButton.GetOnDbClick: TnotifyEvent;
begin
result := FPanel.OnDblClick;//双击
end;procedure TKtvButton.SetOnclick(AValue: TnotifyEvent);
begin
//单击以下任一组件都有效
FPanel.OnClick := Avalue;
FLabel1.OnClick := Avalue;
FLabel2.OnClick := Avalue;
FLabel3.OnClick := Avalue;
FLabel4.OnClick := Avalue;
FLabel5.OnClick := Avalue;
FLabel6.OnClick := Avalue;
FLabel7.OnClick := Avalue;
end;procedure TKtvButton.SetOnDbClick(AValue: TnotifyEvent);
begin
//双击以下任一组件都有效
FPanel.OnDblClick := Avalue;
FLabel1.OnDblClick := Avalue;
FLabel2.OnDblClick := Avalue;
FLabel3.OnDblClick := Avalue;
FLabel4.OnDblClick := Avalue;
FLabel5.OnDblClick := Avalue;
FLabel6.OnDblClick := Avalue;
FLabel7.OnDblClick := Avalue;
end;procedure TKtvButton.FSetColorBZ(CValue:TColor);
begin
FPanel.Color:=CValue;//按钮颜色
end;procedure TKtvButton.FSetColorFM(CValue:TColor);
begin
FLabel1.Font.Color:=CValue;
end;procedure TKtvButton.FSetColorFX(CValue:TColor);
begin
FLabel2.Font.Color:=CValue;
end; procedure TKtvButton.FSetColorRS(CValue:TColor);
begin
FLabel3.Font.Color:=CValue;
end;procedure TKtvButton.FSetColorT1(CValue:TColor);
begin
FLabel4.Font.Color:=CValue
end;procedure TKtvButton.FSetColorT2(CValue:TColor);
begin
FLabel5.Font.Color:=CValue;
end; procedure TKtvButton.FSetColorSD(CValue:TColor);
begin
FColorSD:=CValue;//闪动的颜色
end;end.
是哪个控件,应如何处理,请指点。