这还算简单嘛?200分?2000RMB还差不多.
刚才现写一个,今天简直是疯了,不睡觉做好事.
你只要设置FLCOLOR为填充颜色,POSITION就是进度,进度为0-1之间的实数,
例如0.25则会显示25%并且会填充园25%的指定FLCOLOR的颜色,颜色默认为篮色
unit drawShap;
interface
uses
Windows, Messages, SysUtils, Classes, Controls, ExtCtrls,Graphics;
type
TdrawShap = class(TShape)
private
FPosition: Real;
FFlColor:TColor;
procedure SetPosition(const Value: Real);
{ Private declarations }
protected
{ Protected declarations }
public
{ Public declarations }
constructor Create(AOwner:TComponent); override;
property Position:Real read FPosition write SetPosition;
property FlColor:TColor read FFlColor write FFlColor;
published
{ Published declarations }
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('WENYUE', [TdrawShap]);
end;
{ TdrawShap }
constructor TdrawShap.Create(AOwner: TComponent);
begin
FFlColor:=clBlue;
inherited;
self.Brush.Style:=bsClear;
self.Shape:=stCircle;
end;
procedure TdrawShap.SetPosition(const Value: Real);
Var ARect:TRect;
X1,X2,X3,x4,Y1,Y2,Y3,Y4:Integer;
NumStr:String;
DX,DY:Integer;
begin
If (Value>1) then exit;
If Value<0 Then exit;
Refresh;
{ Canvas.Brush.Style:=bsClear;
Canvas.Ellipse(ClientRect);}
FPosition := Value;
ARect:=ClientRect;
X1:=ARect.Left;
X2:=ARect.Right;
Y1:=ARect.Top;
Y2:=ARect.Bottom;
Y3:=Round(ARect.Bottom-(ARect.Bottom-ARect.Top)*Value);
X3:=ARect.Left;
Y4:=Y3;
X4:=ARect.Right;
Canvas.Brush.Style:=bsSolid;
Canvas.Brush.Color:=FFlColor;
Canvas.Chord(X1,Y1,X2,Y2,X3,Y3,X4,Y4);
Canvas.Brush.Style:=bsClear;
NumStr:=IntToStr(Round(Value*100))+'%';
DX:=(ARect.Left+ARect.Right-Canvas.TextWidth(NumStr)) div 2;
DY:=(ARect.Top+ARect.Bottom-Canvas.TextHeight(NumStr)) div 2;
Canvas.TextRect(ARect,DX,DY,NumStr);
end;
end.