当前位置:编程学习 > Delphi >>

怎样触发delphi 中的progressbar

如题,谢谢各位大虾
答案:使用max,step,stepby等属性,大致如下(step : integer):
step := 9000;
progressbar1.Max := step;
progressbar1.Step :=1;
progressbar1.StepBy(250);
delphi帮助有例子(传输文件):
procedure TForm1.Button2Click(Sender: TObject);

const
// On Windows replace, myfile with a pathname such as c:\\autoexec.bat
FName = 'MyFile';
var
F: File;
MyData: array[1..2048] of byte;
BytesRead: LongInt;
begin
AssignFile(F, FName);
try

Reset(F);

ProgressBar1.Max := FileSize(F);

if (ProgressBar1.Max > 10) then

ProgressBar1.Step := ProgressBar1.Max div 10

else

ProgressBar1.Step := ProgressBar1.Max;

while (ProgressBar1.Position < ProgressBar1.Max) do

begin

// read one Step size chunk of data to buffer

BlockRead(F, MyData, ProgressBar1.Step, BytesRead);

// move the ProgressBar Position using StepIt

ProgressBar1.StepIt; // move by Step amount

end;
finally;

CloseFile(F);
end;
end;

上一个:delphi 怎么用递归写Fibonacci函数
下一个:delphi中怎样判断事件触发

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,