type
progressbar = class(TThread)
private
{ Private declarations }
probar: TProgressBar;
posi : integer;
procedure showprogress;
protected
procedure Execute;
override;
public
constructor create(Suspended: Boolean;
ProgressBar: TProgressBar);
end;
constructor progressbar.create(Suspended: Boolean;
ProgressBar: TProgressBar);
begin
inherited create(Suspended);
probar:=progressBar;
end;
procedure progressbar.showprogress;
begin
probar.Position := posi;
end;
procedure progressbar.Execute;
var i : integer;
begin
for i:=1 to 100do
// 1000000 is too slow...
begin
Sleep(1000);
// 延时一秒
posi := i;
Synchronize(showprogress);
Sleep(1);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var p1,p2 : progressbar;
begin
p1 := progressbar.create(true, progressbar1);
p2 := progressbar.create(true, progressbar2);
p1.Resume ;
p2.Resume ;
end;
end.