⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fillblockfrm.pas

📁 MiniHex 1.1 源程序说明 “MiniHex11SrcSource”目录中的所有文件是MiniHex 1.1的主程序; “MiniHex11SrcControls”目录中的是该软件
💻 PAS
字号:
unit FillBlockFrm;

interface

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

type
  TFillBlockData = record
    Fixed: Boolean;
    FixValue: Byte;
    RndFromVal: Integer;
    RndToVal: Integer;
  end;

  TFillBlockForm = class(TForm)
    GroupBox1: TGroupBox;
    Label1: TLabel;
    Label3: TLabel;
    FixValComboBox: TComboBox;
    FixValRadioButton: TRadioButton;
    RndValRadioButton: TRadioButton;
    RndFromEdit: TEdit;
    RndToEdit: TEdit;
    RndFromUpDown: TUpDown;
    RndToUpDown: TUpDown;
    OkButton: TButton;
    CancelButton: TButton;
    procedure OkButtonClick(Sender: TObject);
    procedure CancelButtonClick(Sender: TObject);
    procedure FixValRadioButtonClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
    function CheckValid: Boolean;

  public
    { Public declarations }
    procedure GetData(var Value: TFillBlockData);

  end;

var
  FillBlockForm: TFillBlockForm;

function ShowFillBlockForm(var Value: TFillBlockData): Boolean;

implementation

uses Misc;

{$R *.DFM}

function ShowFillBlockForm(var Value: TFillBlockData): Boolean;
var
  Frm: TFillBlockForm;
begin
  Frm := TFillBlockForm.Create(Application);
  Result := (Frm.ShowModal = mrOk);
  if Result then Frm.GetData(Value);
  Frm.Free;
end;

function TFillBlockForm.CheckValid: Boolean;
var
  i, j: Integer;
begin
  if not IsInt(FixValComboBox.Text) then
  begin
    MessageBox(Handle, '你输入的数值是非法数值!', '错误', 48);
    Result := False;
    Exit;
  end;
  i := StrToInt(FixValComboBox.Text);
  if (i < 0) or (i > 255) then
  begin
    MessageBox(Handle, '固定值必须限制在0-255之间.', '错误', 48);
    FixValComboBox.SelectAll;
    FixValComboBox.SetFocus;
    Result := False;
    Exit;
  end;
  i := RndFromUpDown.Position;
  j := RndToUpDown.Position;
  if (i > j) then
  begin
    MessageBox(Handle, '随机值的起始值必须小于终了值.', '错误', 48);
    Result := False;
    Exit;
  end;
  Result := True;
end;

procedure TFillBlockForm.GetData(var Value: TFillBlockData);
begin
  Value.Fixed := FixValRadioButton.Checked;
  Value.FixValue := StrToIntDef(FixValComboBox.Text, 0);
  Value.RndFromVal := RndFromUpDown.Position;
  Value.RndToVal := RndToUpDown.Position;
end;

procedure TFillBlockForm.OkButtonClick(Sender: TObject);
begin
  if not CheckValid then Exit;
  ModalResult := mrOk;
end;

procedure TFillBlockForm.CancelButtonClick(Sender: TObject);
begin
  ModalResult := mrCancel;
end;

procedure TFillBlockForm.FixValRadioButtonClick(Sender: TObject);
begin
  RndFromUpDown.Enabled := not FixValRadioButton.Checked;
  RndToUpDown.Enabled := not FixValRadioButton.Checked;
  RndFromEdit.Enabled := not FixValRadioButton.Checked;
  RndToEdit.Enabled := not FixValRadioButton.Checked;
  FixValComboBox.Enabled := FixValRadioButton.Checked;
end;

procedure TFillBlockForm.FormCreate(Sender: TObject);
begin
  FixValRadioButtonClick(Sender);
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -