1 | UNIT Unit12_ValueEdit;
|
---|
2 | INTERFACE
|
---|
3 | USES
|
---|
4 | Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
---|
5 | Dialogs, StdCtrls, CrossEdit, Math;
|
---|
6 | TYPE
|
---|
7 | TForm12 = Class(TForm)
|
---|
8 | group: TGroupBox;
|
---|
9 | btn_ok: TButton;
|
---|
10 | btn_cancel: TButton;
|
---|
11 | lbl_current: TLabel;
|
---|
12 | edit_current: TEdit;
|
---|
13 | lbl_new: TLabel;
|
---|
14 | lbl_offset: TLabel;
|
---|
15 | lbl_datatype: TLabel;
|
---|
16 | edit_offset: TEdit;
|
---|
17 | edit_datatype: TEdit;
|
---|
18 | edit_new: TCrossEdit;
|
---|
19 | PROCEDURE btn_cancelClick(Sender: TObject);
|
---|
20 | PROCEDURE btn_okClick(Sender: TObject);
|
---|
21 | PROCEDURE MakeVarInput(objectname:String; offset:LongWord; datatype:Word; current:String; caller:TObject);
|
---|
22 | PRIVATE
|
---|
23 | PUBLIC
|
---|
24 | END;
|
---|
25 |
|
---|
26 | VAR
|
---|
27 | Form12: TForm12;
|
---|
28 |
|
---|
29 |
|
---|
30 | IMPLEMENTATION
|
---|
31 | USES Unit8_binedit,Unit9_data_structures, Unit1_main;
|
---|
32 | {$R *.dfm}
|
---|
33 | VAR
|
---|
34 | caller_win:TForm8;
|
---|
35 | _datatype:Word;
|
---|
36 | _offset:LongWord;
|
---|
37 |
|
---|
38 |
|
---|
39 | PROCEDURE TForm12.MakeVarInput(objectname:String; offset:LongWord; datatype:Word; current:String; caller:TObject);
|
---|
40 | BEGIN
|
---|
41 | caller_win:=TForm8(caller);
|
---|
42 | Form1.Enabled:=False;
|
---|
43 | Self.Visible:=True;
|
---|
44 | group.Caption:='Edit value';
|
---|
45 | _datatype:=datatype;
|
---|
46 | _offset:=offset;
|
---|
47 | IF Length(objectname)>0 THEN group.Caption:=group.Caption+' for '+objectname;
|
---|
48 | edit_offset.Text:='0x'+IntToHex(offset,8);
|
---|
49 | edit_datatype.Text:=GetDataType(datatype);
|
---|
50 | edit_current.Text:=current;
|
---|
51 | edit_new.EditType:=etString;
|
---|
52 | edit_new.Text:='';
|
---|
53 | edit_new.LimitCheck:=False;
|
---|
54 | edit_new.MaxLength:=0;
|
---|
55 | edit_new.Max:=0;
|
---|
56 | edit_new.BorderStyle:=bsSingle;
|
---|
57 | Form12.Width:=300;
|
---|
58 | CASE datatype OF
|
---|
59 | 1..4: BEGIN
|
---|
60 | edit_new.EditType:=etUnsignedInt;
|
---|
61 | edit_new.LimitCheck:=True;
|
---|
62 | edit_new.Max:=Int(Power(256,datatype))-1;
|
---|
63 | END;
|
---|
64 | 5..8: BEGIN
|
---|
65 | edit_new.MaxLength:=2*(datatype-4);
|
---|
66 | edit_new.EditType:=etHex;
|
---|
67 | END;
|
---|
68 | 9: BEGIN
|
---|
69 | edit_new.EditType:=etFloat;
|
---|
70 | edit_new.LimitCheck:=False;
|
---|
71 | END;
|
---|
72 | 10: BEGIN
|
---|
73 | edit_new.EditType:=etBinary;
|
---|
74 | edit_new.LimitCheck:=False;
|
---|
75 | edit_new.MaxLength:=8;
|
---|
76 | END;
|
---|
77 | 10000..65535: BEGIN
|
---|
78 | edit_new.EditType:=etString;
|
---|
79 | edit_new.LimitCheck:=False;
|
---|
80 | edit_new.MaxLength:=datatype-10000;
|
---|
81 | Form12.Width:=700;
|
---|
82 | END;
|
---|
83 | END;
|
---|
84 | edit_new.SetFocus;
|
---|
85 | edit_new.SelectAll;
|
---|
86 | END;
|
---|
87 |
|
---|
88 | PROCEDURE TForm12.btn_okClick(Sender: TObject);
|
---|
89 | BEGIN
|
---|
90 | IF NOT edit_new.NoValidValue THEN BEGIN
|
---|
91 | Form1.Enabled:=True;
|
---|
92 | Self.Visible:=False;
|
---|
93 | caller_win.SetNewValue(_datatype,_offset,edit_new.Text);
|
---|
94 | END;
|
---|
95 | END;
|
---|
96 |
|
---|
97 | PROCEDURE TForm12.btn_cancelClick(Sender: TObject);
|
---|
98 | BEGIN
|
---|
99 | Form1.Enabled:=True;
|
---|
100 | Self.Visible:=False;
|
---|
101 | END;
|
---|
102 |
|
---|
103 | END.
|
---|