📄 datainspfrm.pas
字号:
unit DataInspFrm;
interface
uses
Windows, Messages, SysUtils, Classes,
Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TDataInspForm = class(TForm)
S8Label: TLabel;
S8Edit: TEdit;
U8Label: TLabel;
U8Edit: TEdit;
S16Label: TLabel;
S16Edit: TEdit;
U16Label: TLabel;
U16Edit: TEdit;
S32Label: TLabel;
S32Edit: TEdit;
U32Label: TLabel;
U32Edit: TEdit;
S64Label: TLabel;
S64Edit: TEdit;
SingleLabel: TLabel;
DoubleLabel: TLabel;
Real48Label: TLabel;
SingleEdit: TEdit;
DoubleEdit: TEdit;
Real48Edit: TEdit;
BinaryLabel: TLabel;
BinaryEdit: TEdit;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormCreate(Sender: TObject);
procedure FormResize(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure FormDblClick(Sender: TObject);
procedure EditDblClick(Sender: TObject);
procedure EditKeyPress(Sender: TObject; var Key: Char);
procedure EditExit(Sender: TObject);
procedure FormDeactivate(Sender: TObject);
private
{ Private declarations }
FValuePtr: Pointer;
FMaxByte: Integer;
procedure ShowData;
procedure ClearData;
public
{ Public declarations }
procedure SetData(AValuePtr: Pointer; AMaxByte: Integer);
procedure AdjustItems;
procedure AdjustPos;
end;
var
DataInspForm: TDataInspForm;
procedure ShowDataInspForm(Show: Boolean = True);
implementation
{$R *.DFM}
uses MainFrm, Misc, Radix, OptionFrm;
procedure ShowDataInspForm(Show: Boolean = True);
begin
if Show then
begin
DataInspForm.Show;
DataInspForm.WindowState := wsNormal;
MHMainForm.BringToFront;
end else
begin
DataInspForm.Close;
end;
end;
procedure TDataInspForm.SetData(AValuePtr: Pointer; AMaxByte: Integer);
begin
FValuePtr := AValuePtr;
FMaxByte := AMaxByte;
ShowData;
end;
procedure TDataInspForm.ShowData;
type
PReal48 = ^Real48;
var
P: Pointer;
S: string;
begin
ClearData;
P := FValuePtr;
if FMaxByte >= 1 then
begin
S8Edit.Text := IntToStr(PShortInt(P)^);
U8Edit.Text := IntToStr(PByte(P)^);
IntToStrAsBin(S, PByte(P)^);
BinaryEdit.Text := S;
end;
if FMaxByte >= 2 then
begin
S16Edit.Text := IntToStr(PSmallInt(P)^);
U16Edit.Text := IntToStr(PWord(P)^);
end;
if FMaxByte >= 4 then
begin
S32Edit.Text := IntToStr(PLongInt(P)^);
U32Edit.Text := IntToStr(PLongWord(P)^);
SingleEdit.Text := Format('%2.8e', [PSingle(P)^]);
end;
if FMaxByte >= 6 then
begin
Real48Edit.Text := Format('%2.10e', [PReal48(P)^]);
end;
if FMaxByte >= 8 then
begin
S64Edit.Text := IntToStr(PInt64(P)^);
DoubleEdit.Text := Format('%2.15e', [PDouble(P)^]);
end;
end;
procedure TDataInspForm.ClearData;
begin
S8Edit.Text := '';
U8Edit.Text := '';
S16Edit.Text := '';
U16Edit.Text := '';
S32Edit.Text := '';
U32Edit.Text := '';
S64Edit.Text := '';
SingleEdit.Text := '';
DoubleEdit.Text := '';
Real48Edit.Text := '';
BinaryEdit.Text := '';
end;
procedure TDataInspForm.AdjustItems;
var
Y: Integer;
begin
S8Label.Visible := Options.ShowS8Data;
U8Label.Visible := Options.ShowU8Data;
S16Label.Visible := Options.ShowS16Data;
U16Label.Visible := Options.ShowU16Data;
S32Label.Visible := Options.ShowS32Data;
U32Label.Visible := Options.ShowU32Data;
S64Label.Visible := Options.ShowS64Data;
SingleLabel.Visible := Options.ShowSingleData;
DoubleLabel.Visible := Options.ShowDoubleData;
Real48Label.Visible := Options.ShowReal48Data;
BinaryLabel.Visible := Options.ShowBinaryData;
S8Edit.Visible := Options.ShowS8Data;
U8Edit.Visible := Options.ShowU8Data;
S16Edit.Visible := Options.ShowS16Data;
U16Edit.Visible := Options.ShowU16Data;
S32Edit.Visible := Options.ShowS32Data;
U32Edit.Visible := Options.ShowU32Data;
S64Edit.Visible := Options.ShowS64Data;
SingleEdit.Visible := Options.ShowSingleData;
DoubleEdit.Visible := Options.ShowDoubleData;
Real48Edit.Visible := Options.ShowReal48Data;
BinaryEdit.Visible := Options.ShowBinaryData;
Y := 4;
if S8Edit.Visible then begin S8Label.Top := Y; S8Edit.Top := Y; Inc(Y, 15); end;
if U8Edit.Visible then begin U8Label.Top := Y; U8Edit.Top := Y; Inc(Y, 15); end;
if S16Edit.Visible then begin S16Label.Top := Y; S16Edit.Top := Y; Inc(Y, 15); end;
if U16Edit.Visible then begin U16Label.Top := Y; U16Edit.Top := Y; Inc(Y, 15); end;
if S32Edit.Visible then begin S32Label.Top := Y; S32Edit.Top := Y; Inc(Y, 15); end;
if U32Edit.Visible then begin U32Label.Top := Y; U32Edit.Top := Y; Inc(Y, 15); end;
if S64Edit.Visible then begin S64Label.Top := Y; S64Edit.Top := Y; Inc(Y, 15); end;
if SingleEdit.Visible then begin SingleLabel.Top := Y; SingleEdit.Top := Y; Inc(Y, 15); end;
if DoubleEdit.Visible then begin DoubleLabel.Top := Y; DoubleEdit.Top := Y; Inc(Y, 15); end;
if Real48Edit.Visible then begin Real48Label.Top := Y; Real48Edit.Top := Y; Inc(Y, 15); end;
if BinaryEdit.Visible then begin BinaryLabel.Top := Y; BinaryEdit.Top := Y; Inc(Y, 15); end;
if (Options.DefDataInspPos <> dpLeftTop) and (Options.DefDataInspPos <> dpRightTop) then
Top := BoundsRect.Bottom - (Y + 1) - (Height - ClientHeight);
ClientHeight := Y + 1;
end;
procedure TDataInspForm.AdjustPos;
var
R: TRect;
begin
R := GetWorkAreaRect;
case Options.DefDataInspPos of
dpLeftTop:
begin
Left := 0;
Top := 0;
end;
dpLeftBottom:
begin
Left := 0;
Top := R.Bottom - Height;
end;
dpRightTop:
begin
Left := R.Right - Width;
Top := 0;
end;
dpRightBottom:
begin
Left := R.Right - Width;
Top := R.Bottom - Height;
end;
end;
end;
procedure TDataInspForm.FormCreate(Sender: TObject);
begin
AdjustPos;
end;
procedure TDataInspForm.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
MHMainForm.ViewDataInspItem.Checked := False;
end;
procedure TDataInspForm.FormResize(Sender: TObject);
begin
S8Edit.Width := ClientWidth - S8Edit.Left - 2;
U8Edit.Width := ClientWidth - U8Edit.Left - 2;
S16Edit.Width := ClientWidth - S16Edit.Left - 2;
U16Edit.Width := ClientWidth - U16Edit.Left - 2;
S32Edit.Width := ClientWidth - S32Edit.Left - 2;
U32Edit.Width := ClientWidth - U32Edit.Left - 2;
S64Edit.Width := ClientWidth - S64Edit.Left - 2;
SingleEdit.Width := ClientWidth - SingleEdit.Left - 2;
DoubleEdit.Width := ClientWidth - DoubleEdit.Left - 2;
Real48Edit.Width := ClientWidth - Real48Edit.Left - 2;
BinaryEdit.Width := ClientWidth - BinaryEdit.Left - 2;
end;
procedure TDataInspForm.FormShow(Sender: TObject);
begin
ClearData;
AdjustItems;
end;
procedure TDataInspForm.FormDeactivate(Sender: TObject);
var
i: Integer;
begin
for i := 0 to Self.ControlCount - 1 do
begin
if Self.Controls[i] is TEdit then
begin
with Self.Controls[i] as TEdit do
begin
Color := clBtnFace;
ReadOnly := True;
end;
end;
end;
end;
procedure TDataInspForm.FormDblClick(Sender: TObject);
begin
ShowOptionForm(3);
end;
procedure TDataInspForm.EditDblClick(Sender: TObject);
var
Edit: TEdit;
begin
Edit := (Sender as TEdit);
if Edit.Text <> '' then
begin
//暂无修改数据功能
{
Edit.Color := clWindow;
Edit.SelLength := 0;
Edit.SelStart := Length(Edit.Text);
Edit.ReadOnly := False;
}
end;
end;
procedure TDataInspForm.EditKeyPress(Sender: TObject; var Key: Char);
var
Edit: TEdit;
begin
if Key = #13 then
begin
Key := #0;
Edit := (Sender as TEdit);
Edit.Color := clBtnFace;
Edit.ReadOnly := True;
end;
end;
procedure TDataInspForm.EditExit(Sender: TObject);
var
Edit: TEdit;
begin
Edit := (Sender as TEdit);
Edit.Color := clBtnFace;
Edit.ReadOnly := True;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -