请高手给我多线程进度条的源代码,十分感谢!高分!(100分)

  • 主题发起人 主题发起人 fisker
  • 开始时间 开始时间
看看这两个帖子:
http://www.delphibbs.com/delphibbs/dispq.asp?lid=1993353
http://www.delphibbs.com/delphibbs/dispq.asp?lid=2016628
 
现写一个:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ComCtrls;
type
TmyThread = Class(TThread)
protected
procedure execute;override;
public
Constructor Create;
end;
TForm1 = class(TForm)
pb1: TProgressBar;
btn1: TButton;
procedure btn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
implementation
{$R *.DFM}
{ TmyThread }
constructor TmyThread.Create;
begin
self.Priority :=tpLower;
self.FreeOnTerminate :=true;
form1.pb1.Position:=0;
inherited Create(false);
end;

procedure TmyThread.execute;
begin
while form1.pb1.Position<form1.pb1.Maxdo
begin
form1.pb1.Position :=form1.pb1.Position+1;
sleep(200);
end;

end;

procedure TForm1.btn1Click(Sender: TObject);
begin
TmyThread.Create;
end;

end.
 
后退
顶部