unit2.pas

来自「delphi开发的抄表数据管理系统」· PAS 代码 · 共 64 行

PAS
64
字号
unit Unit2;

interface

uses
  windows,
  Forms,
  Dialogs,
  Classes;

type
  MyThread = class(TThread)
  private
    { Private declarations }
  protected
    procedure Execute; override;
  public
    procedure exit; 
  end;
var
  flg:boolean;
implementation

uses Unit1;

{ Important: Methods and properties of objects in visual components can only be
  used in a method called using Synchronize, for example,

      Synchronize(UpdateCaption);

  and UpdateCaption could look like,

    procedure MyThread.UpdateCaption;
    begin
      Form1.Caption := 'Updated in a thread';
    end; }

{ MyThread }

procedure MyThread.Execute;
begin
  flg:=true;
  Form1.ProgressBar1.Min:=0;
  Form1.ProgressBar1.Max:=99;
  Form1.ProgressBar1.Position:=0;
  while(flg) do
  begin
    sleep(10);
    begin
      Application.ProcessMessages;
      Form1.ProgressBar1.Position:=Form1.ProgressBar1.Position+1;
      if Form1.ProgressBar1.Position=99 then
        Form1.ProgressBar1.Position:=0;
    end;
  end;
end;

procedure MyThread.exit;
begin
  flg:=false;
end;

end.
 

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?