Показать сообщение отдельно
  #4  
Старый 16.10.2007, 13:53
Juster Juster вне форума
Прохожий
 
Регистрация: 18.05.2007
Сообщения: 7
Репутация: 10
По умолчанию

Вот код:
Код:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls, ComCtrls,unit2, Gauges;

type
  TForm1 = class(TForm)
    Button1: TButton;
    GroupBox1: TGroupBox;
    ListBox1: TListBox;
    Timer1: TTimer;
    Label1: TLabel;
    ProgressBar1: TProgressBar;
    Button2: TButton;
    Gauge1: TGauge;
    procedure Button1Click(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  u:integer;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
Var
  MyThread: TMyThread;
begin
  gauge1.Progress:=0;
  u:=1500;
  MyThread := TMyThread.Create(False);
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
  label1.Caption:='Всё';
end;

end.

2-ой модуль:

Код:
unit Unit2;

interface

uses
  Classes;

type
  TMyThread = class(TThread)
  private
    o:integer;
  protected
    procedure ShowResult;
    procedure Execute; override;
  end;

implementation

uses
  SysUtils, Unit1;

procedure TMyThread.ShowResult;
begin
  form1.Gauge1.Progress:=o;
end;

procedure TMyThread.Execute;
begin
  Form1.Timer1.Interval:=u;
  repeat
    o:=round((100*(u-Form1.Timer1.Interval))/u);
    Synchronize(ShowResult);
  until Form1.Timer1.Interval=0;
end;

end.
Ответить с цитированием