source: oup/releases/0.32a/Unit12_ValueEdit.pas@ 1114

Last change on this file since 1114 was 35, checked in by alloc, 18 years ago
File size: 3.4 KB
RevLine 
[35]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, Unit13_rawedit,Unit9_data_structures, Unit1_main;
32{$R *.dfm}
33VAR
34 caller_win_dat:TForm8;
35 caller_win_raw:TForm13;
36 _datatype:Word;
37 _offset:LongWord;
38
39
40PROCEDURE 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 13..16: BEGIN
84 Exit;
85 edit_new.EditType:=etInteger;
86 edit_new.LimitCheck:=True;
87 edit_new.Max:=Int((Power(256,datatype-13)) / 2)-1;
88 edit_new.Min:=1-Int((Power(256,datatype-13)) / 2)-1;
89 END;
90 10000..65535: BEGIN
91 edit_new.EditType:=etString;
92 edit_new.LimitCheck:=False;
93 edit_new.MaxLength:=datatype-10000;
94 Form12.Width:=700;
95 END;
96 END;
97 edit_new.SetFocus;
98 edit_new.SelectAll;
99 END;
100
101PROCEDURE TForm12.btn_okClick(Sender: TObject);
102 BEGIN
103 IF NOT edit_new.NoValidValue THEN BEGIN
104 Form1.Enabled:=True;
105 Self.Visible:=False;
106 IF caller_win_dat=NIL THEN
107 caller_win_raw.SetNewValue(_datatype,_offset,edit_new.Text)
108 ELSE
109 caller_win_dat.SetNewValue(_datatype,_offset,edit_new.Text);
110 END;
111 END;
112
113PROCEDURE TForm12.btn_cancelClick(Sender: TObject);
114 BEGIN
115 Form1.Enabled:=True;
116 Self.Visible:=False;
117 END;
118
119END.
Note: See TracBrowser for help on using the repository browser.