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

📄 gotooffsetfrm.pas

📁 === === === MiniHex 1.61 源程序说明 ============================== “$(MiniHex)Source”目录中的所有
💻 PAS
字号:
unit GotoOffsetFrm;

interface

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

type
  TGotoOffsetData = record
    Offset: Integer;
    OffUnit: Integer;
    Relative: Integer;
  end;

  TGotoOffsetForm = class(TForm)
    GroupBox1: TGroupBox;
    OffsetEdit: TEdit;
    UnitComboBox: TComboBox;
    RelativeRadioGroup: TRadioGroup;
    OkButton: TButton;
    CancelButton: TButton;
    DecRadioButton: TRadioButton;
    HexRadioButton: TRadioButton;
    procedure OkButtonClick(Sender: TObject);
    procedure CancelButtonClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
    function CheckValid: Boolean;
  public
    { Public declarations }
    procedure GetData(var Value: TGotoOffsetData);

  end;

var
  GotoOffsetForm: TGotoOffsetForm;

function ShowGotoOffsetForm(var Value: TGotoOffsetData): Boolean;

implementation

uses Misc, NumBase;

{$R *.DFM}

function ShowGotoOffsetForm(var Value: TGotoOffsetData): Boolean;
var
  Frm: TGotoOffsetForm;
begin
  Frm := TGotoOffsetForm.Create(Application);
  Result := (Frm.ShowModal = mrOk);
  if Result then Frm.GetData(Value);
  Frm.Free;
end;

procedure TGotoOffsetForm.GetData(var Value: TGotoOffsetData);
begin
  if DecRadioButton.Checked then
    Value.Offset := StrToIntDef(OffsetEdit.Text, 0)
  else
    StrToIntAsHex(Value.Offset, OffsetEdit.Text);
  Value.OffUnit := UnitComboBox.ItemIndex;
  Value.Relative := RelativeRadioGroup.ItemIndex;
end;

function TGotoOffsetForm.CheckValid: Boolean;
begin
  Result := True;
  if DecRadioButton.Checked then
  begin
    if not IsDecStr(OffsetEdit.Text) then
    begin
      Result := False;
      MsgBox('偏移值不正确,请重新输入。');
      OffsetEdit.SetFocus;
      OffsetEdit.SelectAll;
      Exit;
    end;
  end else
  begin
    if not IsHexStr(OffsetEdit.Text) then
    begin
      Result := False;
      MsgBox('偏移值不正确,请重新输入。');
      OffsetEdit.SetFocus;
      OffsetEdit.SelectAll;
      Exit;
    end;
  end;
end;

procedure TGotoOffsetForm.FormCreate(Sender: TObject);
begin
  UnitComboBox.ItemIndex := 0;
end;

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

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

end.

⌨️ 快捷键说明

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