Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1 | daniel-mar | 1 | unit tziplist; |
2 | (************************************************************************ |
||
3 | Copyright (C) 2009, 2010 by Russell J. Peters, Roger Aelbrecht, |
||
4 | Eric W. Engler and Chris Vleghert. |
||
5 | |||
6 | This file is part of TZipMaster Version 1.9. |
||
7 | |||
8 | TZipMaster is free software: you can redistribute it and/or modify |
||
9 | it under the terms of the GNU Lesser General Public License as published by |
||
10 | the Free Software Foundation, either version 3 of the License, or |
||
11 | (at your option) any later version. |
||
12 | |||
13 | TZipMaster is distributed in the hope that it will be useful, |
||
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
16 | GNU Lesser General Public License for more details. |
||
17 | |||
18 | You should have received a copy of the GNU Lesser General Public License |
||
19 | along with TZipMaster. If not, see <http://www.gnu.org/licenses/>. |
||
20 | |||
21 | contact: problems@delphizip.org (include ZipMaster in the subject). |
||
22 | updates: http://www.delphizip.org |
||
23 | DelphiZip maillist subscribe at http://www.freelists.org/list/delphizip |
||
24 | ************************************************************************) |
||
25 | |||
26 | |||
27 | interface |
||
28 | |||
29 | uses |
||
30 | Wintypes, Winprocs, Messages, SysUtils, Classes, Graphics, Controls, |
||
31 | Forms, Dialogs, StdCtrls, Grids, ExtCtrls, SortGrid, ZipMstr19; |
||
32 | |||
33 | type |
||
34 | TZipForm = class(TForm) |
||
35 | OpenDialog1: TOpenDialog; |
||
36 | Panel1: TPanel; |
||
37 | Button2: TButton; |
||
38 | ZipFNameLabel: TLabel; |
||
39 | // StringGrid1: TSortGrid; |
||
40 | Label1: TLabel; |
||
41 | procedure FormCreate(Sender: TObject); |
||
42 | procedure Button2Click(Sender: TObject); |
||
43 | procedure FormActivate(Sender: TObject); |
||
44 | procedure StringGrid1BeginSort(Sender: TObject; Col: Longint; |
||
45 | var SortOptions: TSortOptions); |
||
46 | procedure FillGrid; |
||
47 | private |
||
48 | { Private declarations } |
||
49 | public |
||
50 | { Public declarations } |
||
51 | StringGrid1: TSortGrid; |
||
52 | end; |
||
53 | |||
54 | var |
||
55 | ZipForm: TZipForm; |
||
56 | |||
57 | implementation |
||
58 | |||
59 | uses Unit1, printers; |
||
60 | {$R *.DFM} |
||
61 | |||
62 | procedure TZipForm.FormCreate(Sender: TObject); |
||
63 | begin |
||
64 | StringGrid1 := TSortGrid.Create(self); |
||
65 | StringGrid1.Parent := self; |
||
66 | with StringGrid1 do |
||
67 | begin |
||
68 | Left := 0; |
||
69 | Top := 46; |
||
70 | Width := 591; |
||
71 | Height := 318; |
||
72 | Align := alClient; |
||
73 | ColCount := 1; |
||
74 | DefaultRowHeight := 20; |
||
75 | FixedCols := 0; |
||
76 | RowCount := 2; |
||
77 | Font.Charset := DEFAULT_CHARSET; |
||
78 | Font.Color := clBlack; |
||
79 | Font.Height := -13; |
||
80 | Font.Name := 'Arial'; |
||
81 | Font.Style := [fsBold]; |
||
82 | Options := [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goColSizing, goRowSelect, goThumbTracking]; |
||
83 | ParentFont := False; |
||
84 | TabOrder := 2; |
||
85 | CaseSensitive := False; |
||
86 | AlignmentHorz := taLeftJustify; |
||
87 | AlignmentVert := taTopJustify; |
||
88 | ProportionalScrollBars := True; |
||
89 | ExtendedKeys := False; |
||
90 | SortOnClick := True; |
||
91 | FooterFont.Charset := DEFAULT_CHARSET; |
||
92 | FooterFont.Color := clWindowText; |
||
93 | FooterFont.Height := -11; |
||
94 | FooterFont.Name := 'MS Sans Serif'; |
||
95 | FooterFont.Style := []; |
||
96 | PrintOptions.Orientation := poPortrait; |
||
97 | PrintOptions.PageTitleMargin := 0; |
||
98 | PrintOptions.PageFooter := 'date|time|page'; |
||
99 | PrintOptions.HeaderSize := 10; |
||
100 | PrintOptions.FooterSize := 7; |
||
101 | PrintOptions.DateFormat := 'd-mmm-yyyy'; |
||
102 | PrintOptions.TimeFormat := 'h:nn'; |
||
103 | PrintOptions.FromRow := 0; |
||
104 | PrintOptions.ToRow := 0; |
||
105 | PrintOptions.BorderStyle := bsNone; |
||
106 | PrintOptions.MarginBottom := 0; |
||
107 | PrintOptions.MarginLeft := 0; |
||
108 | PrintOptions.MarginTop := 0; |
||
109 | PrintOptions.MarginRight := 0; |
||
110 | WordWrap := False; |
||
111 | OnBeginSort := StringGrid1BeginSort; |
||
112 | RowCount:=1; { first row is fixed, and used for titles } |
||
113 | ColCount:=4; |
||
114 | Cells[0,0] := 'File Name'; |
||
115 | Cells[1,0] := 'Compr Size'; |
||
116 | Cells[2,0] := 'Uncmpr Size'; |
||
117 | Cells[3,0] := 'Date/Time'; |
||
118 | end; |
||
119 | end; |
||
120 | |||
121 | procedure TZipForm.FillGrid; |
||
122 | var |
||
123 | i: Integer; |
||
124 | begin |
||
125 | with StringGrid1 do |
||
126 | begin |
||
127 | { Empty data from string grid } |
||
128 | FixedRows:=0; |
||
129 | RowCount:=1; { remove everything from grid except col titles } |
||
130 | if Form1.ZipMaster1.Count = 0 then |
||
131 | Exit; |
||
132 | |||
133 | for i:=0 to Form1.ZipMaster1.Count-1 do |
||
134 | begin |
||
135 | RowCount := RowCount + 1; |
||
136 | { We have to set fixed rows after the rowcount is more than 1} |
||
137 | FixedRows:=1; |
||
138 | // with TZipDirEntry(Form1.ZipMaster1.ZipContents[i]^) do |
||
139 | with Form1.ZipMaster1[i] do |
||
140 | begin |
||
141 | { The "-1" below is an offset for the row titles } |
||
142 | Cells[0,RowCount-1] := FileName; |
||
143 | Cells[1,RowCount-1] := IntToStr(CompressedSize); |
||
144 | Cells[2,RowCount-1] := IntToStr(UncompressedSize); |
||
145 | Cells[3,RowCount-1] := FormatDateTime('ddddd t',FileDateToDateTime(DateTime)); |
||
146 | end; // end with |
||
147 | end; // end for |
||
148 | end; // end with |
||
149 | end; |
||
150 | |||
151 | procedure TZipForm.Button2Click(Sender: TObject); |
||
152 | begin |
||
153 | Close; |
||
154 | end; |
||
155 | |||
156 | procedure TZipForm.FormActivate(Sender: TObject); |
||
157 | begin |
||
158 | Width:=Form1.Width; |
||
159 | Height:=Form1.Height; |
||
160 | Top:=Form1.Top; |
||
161 | Left:=Form1.Left; |
||
162 | ZipFNameLabel.Caption:=Form1.ZipFName.Caption; |
||
163 | with StringGrid1 do |
||
164 | begin |
||
165 | FixedRows:=0; |
||
166 | RowCount:=1; { remove everything from grid except col titles } |
||
167 | ColWidths[0]:=316; |
||
168 | ColWidths[1]:=84; |
||
169 | ColWidths[2]:=84; |
||
170 | ColWidths[3]:=120; |
||
171 | end; |
||
172 | |||
173 | if FileExists(Form1.ZipFName.Caption) then |
||
174 | { This assignment causes zipfile to be read: } |
||
175 | Form1.ZipMaster1.ZipFileName := Form1.ZipFName.Caption |
||
176 | else |
||
177 | begin |
||
178 | ShowMessage('Error - file not found: ' + Form1.ZipFName.Caption); |
||
179 | Close; |
||
180 | end; |
||
181 | FillGrid; |
||
182 | end; |
||
183 | |||
184 | { This just shows you which column, datatype, and sort order will be used. } |
||
185 | { This is keyed from the SortGrid's OnBeginSort event. } |
||
186 | { You can remove this if you want. } |
||
187 | procedure TZipForm.StringGrid1BeginSort(Sender: TObject; Col: Longint; |
||
188 | var SortOptions: TSortOptions); |
||
189 | var |
||
190 | Order: String; |
||
191 | ColName: String; |
||
192 | begin |
||
193 | if SortOptions.SortDirection=sdAscending then |
||
194 | Order:='Ascending' |
||
195 | else |
||
196 | Order:='Descending'; |
||
197 | ColName:=StringGrid1.Cells[Col,0]; |
||
198 | case SortOptions.SortStyle of |
||
199 | ssNumeric: ShowMessage('Sorting By ' + ColName + ', Numeric, ' + Order); |
||
200 | ssDateTime: ShowMessage('Sorting By ' + ColName + ', Datetime, ' + Order); |
||
201 | ssTime: ShowMessage('Sorting By ' + ColName + ', Time, ' + Order); |
||
202 | ssCustom: ShowMessage('Sorting By ' + ColName + ', Custom, ' + Order); |
||
203 | else |
||
204 | ShowMessage('Sorting By ' + ColName + ', Alpha, ' + Order); |
||
205 | end; |
||
206 | end; |
||
207 | |||
208 | end. |