在 Form中放置了一个Progressbar1,一个label1,
button的代码如下:
procedure TForm1.Button1Click(Sender: TObject);
var
 i,j,k,s:integer;
begin
  for i:=1 to 10 do
    begin
     for j:=1 to 10000 do
      for k:=1 to 10000 do
        begin
         s:=1;
        end;
    label1.Caption:=inttostr(progressbar1.Position);
    progressbar1.StepBy(1);
    end;
end;
为什么label1上的显示不是随着进度依次递增,而是每次执行完之后才改变的.

解决方案 »

  1.   

    label1.Caption:=inttostr(progressbar1.Position);
    this.Update;//<-------这行
        progressbar1.StepBy(1);
      

  2.   

    不好意思,写错了,应该是
    label1.Caption:=inttostr(progressbar1.Position);
    self.Update;//<-------这行
        progressbar1.StepBy(1);
      

  3.   

    ..    
     label1.Caption:=inttostr(progressbar1.Position);
     progressbar1.StepBy(1);
     application.ProcessMessages;//处理应用程序主消息队列中还没有处理的消息
     ..
      

  4.   

    谢谢!belllab(菜鸟)&gxgyj(杰克.逊_Discovery)