unit Unit9;

interface

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

type
  TFrmSearchAllProjectFiles = class(TForm)
    btnSearch: TButton;
    btnCancel: TButton;
    progress: TProgressBar;
    chkcasesensitive: TCheckBox;
    cmbQuery: TComboBox;
    procedure btnCancelClick(Sender: TObject);
    procedure btnSearchClick(Sender: TObject);
    procedure cmbQueryKeyPress(Sender: TObject; var Key: Char);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  FrmSearchAllProjectFiles: TFrmSearchAllProjectFiles;

implementation

uses Unit1;

{$R *.dfm}

procedure TFrmSearchAllProjectFiles.btnCancelClick(Sender: TObject);
begin
  self.Close;
end;

procedure TFrmSearchAllProjectFiles.btnSearchClick(Sender: TObject);
begin
  if btnsearch.Caption = 'Stop' then begin
    MainForm.StopSearchAllFiles();
    self.Close;
    exit;
  end;

  if Length(cmbQuery.Text)=0 then begin
    ShowMessage('Nothing to search');
    exit;
  end;
  btnsearch.Caption := 'Stop';
  //btnsearch.Enabled := false;
  btnCancel.Enabled := false;
  chkcasesensitive.Enabled := false;
  MainForm.SearchAllFiles(cmbQuery.Text, chkcasesensitive.Checked, progress);
  self.Close;
end;

procedure TFrmSearchAllProjectFiles.cmbQueryKeyPress(Sender: TObject;
  var Key: Char);
begin
  if Ord(Key)=13 then begin
    btnSearchClick(Sender);
  end else if Ord(Key)=27 then begin
    btnCancelClick(Sender);
  end;
end;

end.
