unit truncateWin;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls, Vcl.Mask;

type
  TtruncateFrm = class(TForm)
    GroupBox2: TGroupBox;
    rbSelection: TRadioButton;
    rbEntireFile: TRadioButton;
    GroupBox1: TGroupBox;
    rbColumn: TRadioButton;
    eColumn: TLabeledEdit;
    rbSearch: TRadioButton;
    cbOrdinal: TComboBox;
    Label1: TLabel;
    eChr: TEdit;
    Label2: TLabel;
    cbDirection: TComboBox;
    Label3: TLabel;
    cbOffset: TComboBox;
    btnOk: TButton;
    btnCancel: TButton;
    cbReverse: TCheckBox;
    procedure rbColumnClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure eColumnChange(Sender: TObject);
  private
    procedure CheckOKEnabled;
  public
  end;

implementation

{$R *.dfm}

procedure TtruncateFrm.eColumnChange(Sender: TObject);
begin
  CheckOKEnabled;
end;

procedure TtruncateFrm.FormCreate(Sender: TObject);
begin
  rbColumnClick(Sender);
end;

procedure TtruncateFrm.rbColumnClick(Sender: TObject);
begin

  eColumn.Enabled := rbColumn.Checked;

  cbOrdinal.Enabled := rbSearch.Checked;
  eChr.Enabled := rbSearch.Checked;
  cbDirection.Enabled := rbSearch.Checked;
  cbOffset.Enabled := rbSearch.Checked;

  CheckOKEnabled;

end;

procedure TtruncateFrm.CheckOKEnabled;
begin
  btnOK.Enabled :=
    rbColumn.Checked and (Length(eColumn.Text) > 0)
      or
    rbSearch.Checked and (cbOrdinal.ItemIndex <> -1) and (Length(eChr.Text) = 1) and (cbDirection.ItemIndex <> -1) and (cbOffset.ItemIndex <> -1);
end;

end.
