📄 defblockfrm.pas
字号:
unit DefBlockFrm;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TDefBlockData = record
StartOffset: Integer;
EndOffset: Integer;
end;
TDefBlockForm = class(TForm)
OkButton: TButton;
CancelButton: TButton;
GroupBox1: TGroupBox;
Label1: TLabel;
Label2: TLabel;
StartOffsetEdit: TEdit;
EndOffsetEdit: TEdit;
procedure OkButtonClick(Sender: TObject);
procedure CancelButtonClick(Sender: TObject);
private
{ Private declarations }
function CheckValid: Boolean;
public
{ Public declarations }
procedure SetData(Value: TDefBlockData);
procedure GetData(var Value: TDefBlockData);
end;
var
DefBlockForm: TDefBlockForm;
function ShowDefBlockForm(var Value: TDefBlockData): Boolean;
implementation
uses Misc;
{$R *.DFM}
function ShowDefBlockForm(var Value: TDefBlockData): Boolean;
var
Frm: TDefBlockForm;
begin
Frm := TDefBlockForm.Create(Application);
Frm.SetData(Value);
Result := (Frm.ShowModal = mrOk);
if Result then Frm.GetData(Value);
Frm.Free;
end;
function TDefBlockForm.CheckValid: Boolean;
var
S, E: Integer;
begin
if not IsInt(StartOffsetEdit.Text) or not IsInt(EndOffsetEdit.Text) then
begin
MessageBox(Handle, '你输入的数值非法是非法数值。', '错误', 48);
Result := False;
Exit;
end;
S := StrToInt(StartOffsetEdit.Text);
E := StrToInt(EndOffsetEdit.Text);
if S > E then
begin
MessageBox(Handle, '块首的偏移值不能大于块尾的偏移值。', '错误', 48);
Result := False;
Exit;
end;
Result := True;
end;
procedure TDefBlockForm.SetData(Value: TDefBlockData);
begin
if Value.StartOffset < 0 then StartOffsetEdit.Text := ''
else StartOffsetEdit.Text := IntToStr(Value.StartOffset);
if Value.EndOffset < 0 then EndOffsetEdit.Text := ''
else EndOffsetEdit.Text := IntToStr(Value.EndOffset);
end;
procedure TDefBlockForm.GetData(var Value: TDefBlockData);
begin
Value.StartOffset := StrToInt(StartOffsetEdit.Text);
Value.EndOffset := StrToInt(EndOffsetEdit.Text);
end;
procedure TDefBlockForm.OkButtonClick(Sender: TObject);
begin
if not CheckValid then Exit;
ModalResult := mrOk;
end;
procedure TDefBlockForm.CancelButtonClick(Sender: TObject);
begin
ModalResult := mrCancel;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -