unit chrSearchWin;

interface

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

type
  TchrSearchFrm = class(TForm)
    StaticText1: TStaticText;
    rbNonASCII: TRadioButton;
    rbControl: TRadioButton;
    rbNonchars: TRadioButton;
    rbBlock: TRadioButton;
    lbBlocks: TListBox;
    btnOk: TButton;
    btnCancel: TButton;
    procedure FormCreate(Sender: TObject);
    procedure RbClick(Sender: TObject);
    procedure lbBlocksClick(Sender: TObject);
    procedure lbBlocksKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
  private
    procedure CheckBtnEnabled;
  public
  end;

implementation

uses
  UnicodeData;

{$R *.dfm}

procedure TchrSearchFrm.FormCreate(Sender: TObject);
begin
  lbBlocks.Items.BeginUpdate;
  try
    lbBlocks.Items.Clear;
    for var i := 0 to UCD.BMPBlockCount - 1 do
      lbBlocks.Items.Add(UCD.Blocks[i].BlockName);
  finally
    lbBlocks.Items.EndUpdate;
  end;
end;

procedure TchrSearchFrm.lbBlocksClick(Sender: TObject);
begin
  CheckBtnEnabled;
end;

procedure TchrSearchFrm.lbBlocksKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  CheckBtnEnabled;
end;

procedure TchrSearchFrm.RbClick(Sender: TObject);
begin
  lbBlocks.Enabled := rbBlock.Checked;
  CheckBtnEnabled;
end;

procedure TchrSearchFrm.CheckBtnEnabled;
begin
  btnOk.Enabled := not rbBlock.Checked or (lbBlocks.ItemIndex <> -1);
end;

end.
