source: oup/releases/0.16a/Unit8_binedit.pas

Last change on this file was 21, checked in by alloc, 18 years ago
File size: 1.9 KB
Line 
1UNIT Unit8_binedit;
2INTERFACE
3USES
4 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
5 Dialogs, Wrapgrid, StdCtrls, Grids, StrUtils, MPHexEditor, Unit3_data, Unit2_functions,
6 ExtCtrls;
7
8TYPE
9 TForm8 = Class(TForm)
10 list: TListBox;
11 hex: TMPHexEditor;
12 Splitter1: TSplitter;
13 PROCEDURE listClick(Sender: TObject);
14 PROCEDURE FormCloseQuery(Sender: TObject; var CanClose: Boolean);
15 PROCEDURE FormCreate(Sender: TObject);
16 PROCEDURE Recreatelist;
17 PRIVATE
18 PUBLIC
19 END;
20
21VAR
22 Form8: TForm8;
23
24IMPLEMENTATION
25{$R *.dfm}
26VAR
27 fileid:LongWord;
28
29PROCEDURE TForm8.Recreatelist;
30 VAR
31 i:LongWord;
32 BEGIN
33 Form8.list.Items.Clear;
34 FOR i:=0 TO dat_header.Files-1 DO BEGIN
35 IF (dat_files[i].FileType AND $02)=0 THEN
36 Form8.list.Items.Add(dat_files[i].FileName);
37 END;
38 END;
39
40PROCEDURE TForm8.FormCreate(Sender: TObject);
41 BEGIN
42 Form8.Caption:='';
43 fileid:=0;
44 END;
45
46PROCEDURE TForm8.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
47 BEGIN
48 CanClose:=False;
49 Form8.Visible:=False;
50 END;
51
52PROCEDURE TForm8.listClick(Sender: TObject);
53 VAR
54 mem:TMemoryStream;
55 data:Tdata;
56 BEGIN
57 IF hex.Modified THEN BEGIN
58 IF MessageBox(Form8.Handle,PChar('Save changes to file '+dat_files[fileid].FileName+'?'),PChar('Data changed...'),MB_YESNO)=IDYES THEN BEGIN
59 mem:=TMemoryStream.Create;
60 hex.SaveToStream(mem);
61 mem.Seek(0,soFromBeginning);
62 SetLength(data,mem.Size);
63 mem.Read(data[0],mem.Size);
64 mem.Free;
65 SaveDatFile(fileid,data);
66 ShowMessage('Changes saved...');
67 END;
68 END;
69 fileid:=StrToInt(MidStr(list.Items.Strings[list.ItemIndex],1,5));
70 data:=LoadDatFile(fileid);
71 mem:=TMemoryStream.Create;
72 mem.Write(data[0],Length(data));
73 hex.LoadFromStream(mem);
74 mem.Free;
75 END;
76
77END.
Note: See TracBrowser for help on using the repository browser.