在线等待,关于自己创建控件实例的问题 var edit:TEdit;edit:=TEdit.Create(self);edit.parent := self;edit.onchange :=//这里你的事件函数 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 2 tlabel是从TGraphicControl继承下来,没有句柄,焦点。1 声明和它onclick一样的事件; label1.onclick := form1.Myonclick;主要参数要一致哦。 //参看下面控件的onclick事件unit RLed;interfaceuses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,comctrls;type TRLed = class(TGraphicControl) private FColorLow: TColor; FColorHi: TColor; FOrientation: TTrackBarOrientation; FMaxValue: Longint; FBackColor: TColor; FBarSize: word; FPosition: longint; FBreakPos: byte; procedure SetColorHi(const Value: TColor); procedure SetColorLow(const Value: TColor); procedure SetOrientation(const Value: TTrackBarOrientation); procedure SetMaxValue(const Value: Longint); procedure SetBackColor(const Value: TColor); procedure SetBarSize(const Value: word); procedure SetPosition(const Value: longint); procedure SetBreakPos(const Value: byte); { Private declarations } protected { Protected declarations } BarCount:longint; procedure Paint; override; procedure RecalcBarCount; function BlendColor(clr: TColor): TColor; function inHi(I: Integer;Pro:byte): boolean; public { Public declarations } constructor Create(Owner: TComponent); override; destructor Destroy; override; function InPos(i: Integer): boolean; published { Published declarations } property ColorLow:TColor read FColorLow write SetColorLow; property ColorHi:TColor read FColorHi write SetColorHi; property Orientation:TTrackBarOrientation read FOrientation write SetOrientation default trVertical; property MaxValue: Longint read FMaxValue write SetMaxValue; property BackColor:TColor read FBackColor write SetBackColor; property BarSize:word read FBarSize write SetBarSize; property Position:longint read FPosition write SetPosition; property BreakPos:byte read FBreakPos write SetBreakPos; property Constraints; property ParentShowHint; property PopupMenu; property ShowHint; property Visible; property Align; property Anchors; property OnClick; property OnDragDrop; property OnDragOver; property OnEndDock; property OnEndDrag; property OnMouseDown; property OnMouseMove; property OnMouseUp; property OnStartDock; property OnStartDrag; property DragCursor; property DragKind; property DragMode; end;procedure Register;implementationprocedure Register;begin RegisterComponents('Ray Adams', [TRLed]);end;{ TRLed }function TRLed.BlendColor(clr: TColor): TColor;beginResult:=rgb(GetRValue(clr) div 2,GetgValue(clr)div 2,GetbValue(clr)div 2);end;constructor TRLed.Create(Owner: TComponent);begininherited CReate(Owner);Width := 25; // Change inherited propertiesHeight := 152;FMaxValue:=100;FBackColor:=clBlack;FColorLow:=clLime;FColorHi:=clRed;rgb(255,0,0);FBarSize:=5;FOrientation:=trVertical;FPOsition:=0;FBreakPos:=35;RecalcBarCount;end;destructor TRLed.Destroy;begininherited Destroy;end;function TRLed.inHi;beginresult:=i<Round(BarCount/100*Pro);end;function TRLed.InPos(i: Integer): boolean;var bTemp:byte;beginbTemp:=round((FPosition / FMaxValue) * 100);result:=i>BarCount-Round(BarCount/100*bTemp);end;procedure TRLed.Paint;var TB:TBitmap; i:word;beginTB:=TBitmap.create;tb.Width:=Width;tb.Height:=Height;tb.Canvas.Brush.Color:=BAckColor;tb.Canvas.FillRect(rect(0,0,Width,Height));RecalcBarCount;case FOrientation oftrVertical:begin for i:=1 to BarCount do begin if inHi(i,FBreakPos) then if not InPos(i) then tb.Canvas.Brush.Color:=BlendCOlor(ColorHi) else tb.Canvas.Brush.Color:=ColorHi else if not InPos(i) then tb.Canvas.Brush.Color:=BlendCOlor(ColorLow) else tb.Canvas.Brush.Color:=ColorLow; tb.Canvas.FillRect(rect(2,(i-1)*barSize+2,width-2,(i-1)*barSize+BarSize)); end; end; trHorizontal:begin for i:=1 to BarCount do begin if inHi(BarCount-i,FBreakPos) then if not InPos(BarCount-i+1) then tb.Canvas.Brush.Color:=BlendCOlor(ColorHi) else tb.Canvas.Brush.Color:=ColorHi else if not InPos(BarCount-i+1) then tb.Canvas.Brush.Color:=BlendCOlor(ColorLow) else tb.Canvas.Brush.Color:=ColorLow; tb.Canvas.FillRect(rect((i-1)*barSize+2,2,(i-1)*barSize+BarSize,height-2)); end; end;end;Canvas.CopyRect(Rect(0,0,width,height),tb.canvas,Rect(0,0,width,height));TB.free;end;procedure TRLed.RecalcBarCount;beginif FOrientation=trVertical thenBarCount:=(Height-2) div (FBarSize)elseBarCount:=(Width-2) div (FBarSize)end;procedure TRLed.SetBackColor(const Value: TColor);begin FBackColor := Value; paint;end;procedure TRLed.SetBarSize(const Value: word);begin if (FBarSize <> Value) and ((FOrientation=trVertical) and (Value<Height-4)) or ((FOrientation=trHorizontal) and (Value<Width-4)) then begin FBarSize := Value; RecalcBarCount; Paint; end;end;procedure TRLed.SetBreakPos(const Value: byte);begin if not Value>100 then begin FBreakPos := Value; Paint; end;end;procedure TRLed.SetColorHi(const Value: TColor);begin FColorHi := Value; Paint;end;procedure TRLed.SetColorLow(const Value: TColor);begin if FColorLow <>Value then begin FColorLow := Value; Paint; end;end;procedure TRLed.SetMaxValue(const Value: Longint);begin if FMaxValue <> Value then begin FMaxValue := Value; Paint; end;end;procedure TRLed.SetOrientation(const Value: TTrackBarOrientation);begin if FOrientation <> Value then begin FOrientation := Value; //Change Orientation if ComponentState * [csLoading, csUpdating] = [] then SetBounds(Left, Top, Height, Width); Paint; end;end;procedure TRLed.SetPosition(const Value: longint);begin if Value<=FMaxValue then begin FPosition := Value; Paint; end;end;end. UPDATE SET 简单的问题 一个程序中有N个选择年月的窗口,怎么做得一样呀? 感谢ARI的帮忙 求助,各位高手谁有rave的说明文档。 QuickReport是否可以套打?如何套打? 突然忘了选择语句的结构,在线等待........ :) 我现在成陆军上尉了! 小问题?关于csdn!! 随着Kylix的推出是否意味着Delphi程序员的身价会大涨? 请求帮忙,我给20分 給記錄編號問題﹗ Delphi中可以使用Oracle的包里的函数,并取得返回值吗?
1 声明和它onclick一样的事件;
label1.onclick := form1.Myonclick;
主要参数要一致哦。
unit RLed;interfaceuses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,comctrls;type
TRLed = class(TGraphicControl)
private
FColorLow: TColor;
FColorHi: TColor;
FOrientation: TTrackBarOrientation;
FMaxValue: Longint;
FBackColor: TColor;
FBarSize: word;
FPosition: longint;
FBreakPos: byte;
procedure SetColorHi(const Value: TColor);
procedure SetColorLow(const Value: TColor);
procedure SetOrientation(const Value: TTrackBarOrientation);
procedure SetMaxValue(const Value: Longint);
procedure SetBackColor(const Value: TColor);
procedure SetBarSize(const Value: word);
procedure SetPosition(const Value: longint);
procedure SetBreakPos(const Value: byte);
{ Private declarations }
protected
{ Protected declarations }
BarCount:longint;
procedure Paint; override;
procedure RecalcBarCount;
function BlendColor(clr: TColor): TColor;
function inHi(I: Integer;Pro:byte): boolean;
public
{ Public declarations }
constructor Create(Owner: TComponent); override;
destructor Destroy; override;
function InPos(i: Integer): boolean;
published
{ Published declarations }
property ColorLow:TColor read FColorLow write SetColorLow;
property ColorHi:TColor read FColorHi write SetColorHi;
property Orientation:TTrackBarOrientation read FOrientation write SetOrientation default trVertical;
property MaxValue: Longint read FMaxValue write SetMaxValue;
property BackColor:TColor read FBackColor write SetBackColor;
property BarSize:word read FBarSize write SetBarSize;
property Position:longint read FPosition write SetPosition;
property BreakPos:byte read FBreakPos write SetBreakPos;
property Constraints;
property ParentShowHint;
property PopupMenu;
property ShowHint;
property Visible;
property Align;
property Anchors;
property OnClick;
property OnDragDrop;
property OnDragOver;
property OnEndDock;
property OnEndDrag;
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
property OnStartDock;
property OnStartDrag;
property DragCursor;
property DragKind;
property DragMode;
end;procedure Register;implementationprocedure Register;
begin
RegisterComponents('Ray Adams', [TRLed]);
end;{ TRLed }function TRLed.BlendColor(clr: TColor): TColor;
begin
Result:=rgb(GetRValue(clr) div 2,GetgValue(clr)div 2,GetbValue(clr)div 2);
end;constructor TRLed.Create(Owner: TComponent);
begin
inherited CReate(Owner);
Width := 25; // Change inherited properties
Height := 152;
FMaxValue:=100;
FBackColor:=clBlack;
FColorLow:=clLime;
FColorHi:=clRed;
rgb(255,0,0);
FBarSize:=5;
FOrientation:=trVertical;
FPOsition:=0;
FBreakPos:=35;
RecalcBarCount;
end;destructor TRLed.Destroy;
begin
inherited Destroy;
end;function TRLed.inHi;
begin
result:=i<Round(BarCount/100*Pro);
end;function TRLed.InPos(i: Integer): boolean;
var bTemp:byte;
begin
bTemp:=round((FPosition / FMaxValue) * 100);
result:=i>BarCount-Round(BarCount/100*bTemp);
end;procedure TRLed.Paint;
var TB:TBitmap;
i:word;
begin
TB:=TBitmap.create;
tb.Width:=Width;
tb.Height:=Height;
tb.Canvas.Brush.Color:=BAckColor;
tb.Canvas.FillRect(rect(0,0,Width,Height));
RecalcBarCount;
case FOrientation of
trVertical:begin
for i:=1 to BarCount do
begin
if inHi(i,FBreakPos) then if not InPos(i) then tb.Canvas.Brush.Color:=BlendCOlor(ColorHi)
else tb.Canvas.Brush.Color:=ColorHi
else if not InPos(i) then tb.Canvas.Brush.Color:=BlendCOlor(ColorLow)
else tb.Canvas.Brush.Color:=ColorLow;
tb.Canvas.FillRect(rect(2,(i-1)*barSize+2,width-2,(i-1)*barSize+BarSize));
end;
end;
trHorizontal:begin
for i:=1 to BarCount do
begin
if inHi(BarCount-i,FBreakPos) then if not InPos(BarCount-i+1) then tb.Canvas.Brush.Color:=BlendCOlor(ColorHi)
else tb.Canvas.Brush.Color:=ColorHi
else if not InPos(BarCount-i+1) then tb.Canvas.Brush.Color:=BlendCOlor(ColorLow)
else tb.Canvas.Brush.Color:=ColorLow;
tb.Canvas.FillRect(rect((i-1)*barSize+2,2,(i-1)*barSize+BarSize,height-2));
end;
end;
end;
Canvas.CopyRect(Rect(0,0,width,height),tb.canvas,Rect(0,0,width,height));
TB.free;
end;procedure TRLed.RecalcBarCount;
begin
if FOrientation=trVertical then
BarCount:=(Height-2) div (FBarSize)
else
BarCount:=(Width-2) div (FBarSize)
end;procedure TRLed.SetBackColor(const Value: TColor);
begin
FBackColor := Value;
paint;
end;procedure TRLed.SetBarSize(const Value: word);
begin
if (FBarSize <> Value) and
((FOrientation=trVertical)
and
(Value<Height-4))
or
((FOrientation=trHorizontal)
and
(Value<Width-4))
then
begin
FBarSize := Value;
RecalcBarCount;
Paint;
end;
end;procedure TRLed.SetBreakPos(const Value: byte);
begin
if not Value>100 then
begin
FBreakPos := Value;
Paint;
end;
end;procedure TRLed.SetColorHi(const Value: TColor);
begin
FColorHi := Value;
Paint;
end;procedure TRLed.SetColorLow(const Value: TColor);
begin
if FColorLow <>Value then
begin
FColorLow := Value;
Paint;
end;
end;procedure TRLed.SetMaxValue(const Value: Longint);
begin
if FMaxValue <> Value then
begin
FMaxValue := Value;
Paint;
end;
end;procedure TRLed.SetOrientation(const Value: TTrackBarOrientation);
begin
if FOrientation <> Value then
begin
FOrientation := Value;
//Change Orientation
if ComponentState * [csLoading, csUpdating] = [] then
SetBounds(Left, Top, Height, Width);
Paint;
end;
end;procedure TRLed.SetPosition(const Value: longint);
begin
if Value<=FMaxValue then
begin
FPosition := Value;
Paint;
end;
end;end.