source: oup/releases/0.23a/Unit12_ValueEdit.pas@ 333

Last change on this file since 333 was 23, checked in by alloc, 18 years ago
File size: 2.8 KB
Line 
1UNIT Unit12_ValueEdit;
2INTERFACE
3USES
4 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
5 Dialogs, StdCtrls, CrossEdit, Math;
6TYPE
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
26VAR
27 Form12: TForm12;
28
29
30IMPLEMENTATION
31USES Unit8_binedit,Unit9_data_structures, Unit1_main;
32{$R *.dfm}
33VAR
34 caller_win:TForm8;
35 _datatype:Word;
36 _offset:LongWord;
37
38
39PROCEDURE 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 Form12.Width:=300;
57 CASE datatype OF
58 1..4: BEGIN
59 edit_new.EditType:=etUnsignedInt;
60 edit_new.LimitCheck:=True;
61 edit_new.Max:=Int(Power(256,datatype))-1;
62 END;
63 5..8: BEGIN
64 edit_new.MaxLength:=2*(datatype-4);
65 edit_new.EditType:=etHex;
66 END;
67 9: BEGIN
68 edit_new.EditType:=etFloat;
69 edit_new.LimitCheck:=False;
70 END;
71 10: BEGIN
72 edit_new.EditType:=etBinary;
73 edit_new.LimitCheck:=False;
74 edit_new.MaxLength:=8;
75 END;
76 10000..65535: BEGIN
77 edit_new.EditType:=etString;
78 edit_new.LimitCheck:=False;
79 edit_new.MaxLength:=datatype-10000;
80 Form12.Width:=700;
81 END;
82 END;
83 edit_new.SetFocus;
84 edit_new.SelectAll;
85 END;
86
87PROCEDURE TForm12.btn_okClick(Sender: TObject);
88 BEGIN
89 IF NOT edit_new.NoValidValue THEN BEGIN
90 Form1.Enabled:=True;
91 Self.Visible:=False;
92 caller_win.SetNewValue(_datatype,_offset,edit_new.Text);
93 END;
94 END;
95
96PROCEDURE TForm12.btn_cancelClick(Sender: TObject);
97 BEGIN
98 Form1.Enabled:=True;
99 Self.Visible:=False;
100 END;
101
102END.
Note: See TracBrowser for help on using the repository browser.