[8] | 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, Unit13_rawedit,Unit9_data_structures, Unit1_main;
|
---|
| 32 | {$R *.dfm}
|
---|
| 33 | VAR
|
---|
| 34 | caller_win_dat:TForm8;
|
---|
| 35 | caller_win_raw:TForm13;
|
---|
| 36 | _datatype:Word;
|
---|
| 37 | _offset:LongWord;
|
---|
| 38 |
|
---|
| 39 |
|
---|
| 40 | PROCEDURE TForm12.MakeVarInput(objectname:String; offset:LongWord; datatype:Word; current:String; caller:TObject);
|
---|
| 41 | BEGIN
|
---|
| 42 | caller_win_dat:=NIL;
|
---|
| 43 | caller_win_raw:=NIL;
|
---|
| 44 | IF Pos('rawedit',TComponent(caller).Name)>0 THEN
|
---|
| 45 | caller_win_raw:=TForm13(caller)
|
---|
| 46 | ELSE
|
---|
| 47 | caller_win_dat:=TForm8(caller);
|
---|
| 48 | Form1.Enabled:=False;
|
---|
| 49 | Self.Visible:=True;
|
---|
| 50 | group.Caption:='Edit value';
|
---|
| 51 | _datatype:=datatype;
|
---|
| 52 | _offset:=offset;
|
---|
| 53 | IF Length(objectname)>0 THEN group.Caption:=group.Caption+' for '+objectname;
|
---|
| 54 | edit_offset.Text:='0x'+IntToHex(offset,8);
|
---|
| 55 | edit_datatype.Text:=GetDataType(datatype);
|
---|
| 56 | edit_current.Text:=current;
|
---|
| 57 | edit_new.EditType:=etString;
|
---|
| 58 | edit_new.Text:='';
|
---|
| 59 | edit_new.LimitCheck:=False;
|
---|
| 60 | edit_new.MaxLength:=0;
|
---|
| 61 | edit_new.Max:=0;
|
---|
| 62 | edit_new.BorderStyle:=bsSingle;
|
---|
| 63 | Form12.Width:=300;
|
---|
| 64 | CASE datatype OF
|
---|
| 65 | 1..4: BEGIN
|
---|
| 66 | edit_new.EditType:=etUnsignedInt;
|
---|
| 67 | edit_new.LimitCheck:=True;
|
---|
| 68 | edit_new.Max:=Int(Power(256,datatype))-1;
|
---|
| 69 | END;
|
---|
| 70 | 5..8: BEGIN
|
---|
| 71 | edit_new.MaxLength:=2*(datatype-4);
|
---|
| 72 | edit_new.EditType:=etHex;
|
---|
| 73 | END;
|
---|
| 74 | 9: BEGIN
|
---|
| 75 | edit_new.EditType:=etFloat;
|
---|
| 76 | edit_new.LimitCheck:=False;
|
---|
| 77 | END;
|
---|
| 78 | 10: BEGIN
|
---|
| 79 | edit_new.EditType:=etBinary;
|
---|
| 80 | edit_new.LimitCheck:=False;
|
---|
| 81 | edit_new.MaxLength:=8;
|
---|
| 82 | END;
|
---|
| 83 | 10000..65535: BEGIN
|
---|
| 84 | edit_new.EditType:=etString;
|
---|
| 85 | edit_new.LimitCheck:=False;
|
---|
| 86 | edit_new.MaxLength:=datatype-10000;
|
---|
| 87 | Form12.Width:=700;
|
---|
| 88 | END;
|
---|
| 89 | END;
|
---|
| 90 | edit_new.SetFocus;
|
---|
| 91 | edit_new.SelectAll;
|
---|
| 92 | END;
|
---|
| 93 |
|
---|
| 94 | PROCEDURE TForm12.btn_okClick(Sender: TObject);
|
---|
| 95 | BEGIN
|
---|
| 96 | IF NOT edit_new.NoValidValue THEN BEGIN
|
---|
| 97 | Form1.Enabled:=True;
|
---|
| 98 | Self.Visible:=False;
|
---|
| 99 | IF caller_win_dat=NIL THEN
|
---|
| 100 | caller_win_raw.SetNewValue(_datatype,_offset,edit_new.Text)
|
---|
| 101 | ELSE
|
---|
| 102 | caller_win_dat.SetNewValue(_datatype,_offset,edit_new.Text);
|
---|
| 103 | END;
|
---|
| 104 | END;
|
---|
| 105 |
|
---|
| 106 | PROCEDURE TForm12.btn_cancelClick(Sender: TObject);
|
---|
| 107 | BEGIN
|
---|
| 108 | Form1.Enabled:=True;
|
---|
| 109 | Self.Visible:=False;
|
---|
| 110 | END;
|
---|
| 111 |
|
---|
| 112 | END.
|
---|