新建一个工程1 // 把下面字符串拷贝到窗体上(在IDE的窗体设计中拷贝)
object pbProgress: TDrawGrid
Left = 76
Top = 32
Width = 301
Height = 25
Color = clInfoBk
ColCount = 100
Ctl3D = False
DefaultColWidth = 2
DefaultRowHeight = 30
Enabled = False
FixedCols = 0
RowCount = 1
FixedRows = 0
ParentCtl3D = False
ScrollBars = ssNone
TabOrder = 0
end2 增加如下变量
fProgress: Integer;
fRandomColor: integer;3 放置一个Timer控件, 时间间隔设成100ms好了procedure TForm1.FormCreate(Sender: TObject);
begin
fProgress := 0;
Randomize();
fRandomColor := Random(255);
end;// pbProgress的DrawCell事件
procedure TForm1.pbProgressDrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState);
begin
pbProgress.Canvas.Brush.Color := RGB(aCol * 255 div 100, (100 - aCol) * 255 div 100, fRandomColor);
if aCol <= fProgress then
pbProgress.Canvas.FillRect(Rect);
end;procedure TForm1.Timer1Timer(Sender: TObject);
begin
fProgress := fProgress + 1;
pbProgress.Repaint;
Application.ProcessMessages;
end;几下就弄出一个进度条, 有兴趣的TryTry
object pbProgress: TDrawGrid
Left = 76
Top = 32
Width = 301
Height = 25
Color = clInfoBk
ColCount = 100
Ctl3D = False
DefaultColWidth = 2
DefaultRowHeight = 30
Enabled = False
FixedCols = 0
RowCount = 1
FixedRows = 0
ParentCtl3D = False
ScrollBars = ssNone
TabOrder = 0
end2 增加如下变量
fProgress: Integer;
fRandomColor: integer;3 放置一个Timer控件, 时间间隔设成100ms好了procedure TForm1.FormCreate(Sender: TObject);
begin
fProgress := 0;
Randomize();
fRandomColor := Random(255);
end;// pbProgress的DrawCell事件
procedure TForm1.pbProgressDrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState);
begin
pbProgress.Canvas.Brush.Color := RGB(aCol * 255 div 100, (100 - aCol) * 255 div 100, fRandomColor);
if aCol <= fProgress then
pbProgress.Canvas.FillRect(Rect);
end;procedure TForm1.Timer1Timer(Sender: TObject);
begin
fProgress := fProgress + 1;
pbProgress.Repaint;
Application.ProcessMessages;
end;几下就弄出一个进度条, 有兴趣的TryTry
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货