unit ExProg;

interface

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

type
  TExProgress = class(TForm)
    Label1: TLabel;
    Gauge: TGauge;
    Label2: TLabel;
    CancelButton: TButton;
    Edit: TEdit;
    StopButton: TButton;
    Bevel: TBevel;
    StatusBar: TStatusBar;
    procedure FormShow(Sender: TObject);
    procedure FormHide(Sender: TObject);
    procedure StopButtonClick(Sender: TObject);
    procedure CancelButtonClick(Sender: TObject);
  private
  public
    Stop      : Boolean;
    Cancel    : Boolean;
  end;

var
  ExProgress: TExProgress;

implementation

{$R *.DFM}

procedure TExProgress.FormShow(Sender: TObject);
begin
  //  Мы готовимся захватить ресурсы процессора. Будем вежливы по
  //  отношению к другим прогграммам:
  Windows.SetPriorityClass(Windows.GetModuleHandle(nil),
    IDLE_PRIORITY_CLASS);
  Stop:=False;
  Cancel:=False;
end;

procedure TExProgress.FormHide(Sender: TObject);
begin
  Windows.SetPriorityClass(Windows.GetModuleHandle(nil),
    NORMAL_PRIORITY_CLASS);
end;

procedure TExProgress.StopButtonClick(Sender: TObject);
begin
  Stop:=True;
end;

procedure TExProgress.CancelButtonClick(Sender: TObject);
begin
  Cancel:=True;
end;

end.

