/[projects]/dao/DelphiScanner/Components/tpsystools_4.04/examples/Delphi/ExBarCU.pas
ViewVC logotype

Contents of /dao/DelphiScanner/Components/tpsystools_4.04/examples/Delphi/ExBarCU.pas

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2671 - (show annotations) (download)
Tue Aug 25 18:15:15 2015 UTC (8 years, 9 months ago) by torben
File size: 13224 byte(s)
Added tpsystools component
1 (* ***** BEGIN LICENSE BLOCK *****
2 * Version: MPL 1.1
3 *
4 * The contents of this file are subject to the Mozilla Public License Version
5 * 1.1 (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
7 * http://www.mozilla.org/MPL/
8 *
9 * Software distributed under the License is distributed on an "AS IS" basis,
10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 * for the specific language governing rights and limitations under the
12 * License.
13 *
14 * The Original Code is TurboPower SysTools
15 *
16 * The Initial Developer of the Original Code is
17 * TurboPower Software
18 *
19 * Portions created by the Initial Developer are Copyright (C) 1996-2002
20 * the Initial Developer. All Rights Reserved.
21 *
22 * Contributor(s):
23 *
24 * ***** END LICENSE BLOCK ***** *)
25
26 unit ExBarCU;
27
28 interface
29
30 uses
31 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
32 StdCtrls, Printers, ExtCtrls, Tabnotbk, ComCtrls, Grids,
33 Db, DBTables, DBCtrls, DBGrids,
34
35 StBase, StBarC, StDbBarC, St2DBarC;
36
37 type
38 TBarCodeForm = class(TForm)
39 btnPrint: TButton;
40 PrintDialog1: TPrintDialog;
41 NB: TTabbedNotebook;
42 edCode1: TEdit;
43 edSupp: TEdit;
44 Label1: TLabel;
45 BarCode1: TStBarCode;
46 btnCopy: TButton;
47 BarCode2: TStBarCode;
48 BarCode5: TStBarCode;
49 rgType: TRadioGroup;
50 cbSupp: TCheckBox;
51 btnClose: TButton;
52 cbTallGuardBars: TCheckBox;
53 cbShowCode: TCheckBox;
54 btnUpdate1: TButton;
55 cbBearerBars: TCheckBox;
56 cbShowCode2: TCheckBox;
57 Label2: TLabel;
58 edCode2: TEdit;
59 btnUpdate2: TButton;
60 BarCode7: TStBarCode;
61 DataSource1: TDataSource;
62 Table1: TTable;
63 DBGrid1: TDBGrid;
64 btnSave: TButton;
65 BarCode6: TStBarCode;
66 StDbBarCode1: TStDbBarCode;
67 Label3: TLabel;
68 edCode3: TEdit;
69 Button2: TButton;
70 cbShowCode3: TCheckBox;
71 BarCode3: TStBarCode;
72 Label4: TLabel;
73 cbShowGuardChars3: TCheckBox;
74 cbShowCode4: TCheckBox;
75 BarCode4: TStBarCode;
76 Button1: TButton;
77 edCode4: TEdit;
78 Label5: TLabel;
79 Label6: TLabel;
80 edCode5: TEdit;
81 btnUpdate5: TButton;
82 cbShowCode5: TCheckBox;
83 Label7: TLabel;
84 edCode6: TEdit;
85 btnUpdate6: TButton;
86 cbShowCode6: TCheckBox;
87 Label8: TLabel;
88 edCode7: TEdit;
89 btnUpdate7: TButton;
90 cbShowCode7: TCheckBox;
91 Label9: TLabel;
92 edCodePDF417: TEdit;
93 btnUpdatePDF417: TButton;
94 cbShowCodePDF417: TCheckBox;
95 Label10: TLabel;
96 edCodeMaxiCode: TEdit;
97 btnUpdateMaxiCode: TButton;
98 cbShowCodeMaxiCode: TCheckBox;
99 radMCMode23: TRadioButton;
100 radMCMode4: TRadioButton;
101 radMCMode5: TRadioButton;
102 Label11: TLabel;
103 edMCCountryCode: TEdit;
104 edMCPostalCode: TEdit;
105 edMCServiceClass: TEdit;
106 Label12: TLabel;
107 Label13: TLabel;
108 Label14: TLabel;
109 cbPDF417Truncated: TCheckBox;
110 StPDF417Barcode1: TStPDF417Barcode;
111 StMaxiCodeBarcode1: TStMaxiCodeBarcode;
112 btnValidate: TButton;
113 procedure btnPrintClick(Sender: TObject);
114 procedure btnCopyClick(Sender: TObject);
115 procedure btnValidateClick(Sender: TObject);
116 procedure btnUpdate1Click(Sender: TObject);
117 procedure btnCloseClick(Sender: TObject);
118 procedure btnSaveClick(Sender: TObject);
119 procedure btnUpdate2Click(Sender: TObject);
120 procedure btnUpdate3Click(Sender: TObject);
121 procedure btnUpdate4Click(Sender: TObject);
122 procedure btnUpdate5Click(Sender: TObject);
123 procedure btnUpdate6Click(Sender: TObject);
124 procedure btnUpdate7Click(Sender: TObject);
125 procedure btnUpdatePDF417Click(Sender: TObject);
126 procedure btnUpdateMaxiCodeClick(Sender: TObject);
127 procedure radMCMode4Click(Sender: TObject);
128 procedure radMCMode23Click(Sender: TObject);
129 procedure radMCMode5Click(Sender: TObject);
130 procedure NBChange(Sender: TObject; NewTab: Integer;
131 var AllowChange: Boolean);
132 private
133 { Private declarations }
134 public
135 { Public declarations }
136 end;
137
138 var
139 BarCodeForm: TBarCodeForm;
140
141 implementation
142
143 {$R *.DFM}
144
145 procedure TBarCodeForm.btnPrintClick(Sender: TObject);
146 begin
147 if not PrintDialog1.Execute then
148 Exit;
149 Application.ProcessMessages;
150
151 Screen.Cursor := crHourGlass;
152 try
153 Printer.BeginDoc;
154 try
155 Printer.Title := 'StBarCode';
156
157 BarCode1.BarcodeType := bcUPC_A;
158 BarCode1.Code := '52100014015';
159 BarCode1.SupplementalCode := '';
160 BarCode1.PaintToCanvasSize(Printer.Canvas, 0.5, 0.5, 0.5);
161 BarCode1.SupplementalCode := '12';
162 BarCode1.PaintToCanvasSize(Printer.Canvas, 3.0, 0.5, 0.5);
163 BarCode1.SupplementalCode := '12345';
164 BarCode1.PaintToCanvasSize(Printer.Canvas, 6.0, 0.5, 0.5);
165
166 BarCode1.BarcodeType :=bcUPC_E;
167 BarCode1.Code := '173559';
168 BarCode1.SupplementalCode := '';
169 BarCode1.PaintToCanvasSize(Printer.Canvas, 0.5, 1.5, 0.5);
170 BarCode1.SupplementalCode := '12';
171 BarCode1.PaintToCanvasSize(Printer.Canvas, 3.0, 1.5, 0.5);
172 BarCode1.SupplementalCode := '12345';
173 BarCode1.PaintToCanvasSize(Printer.Canvas, 6.0, 1.5, 0.5);
174
175 BarCode1.BarcodeType := bcEAN_13;
176 BarCode1.Code := '737622135746';
177 BarCode1.SupplementalCode := '';
178 BarCode1.PaintToCanvasSize(Printer.Canvas, 0.5, 2.5, 0.5);
179 BarCode1.SupplementalCode := '12';
180 BarCode1.PaintToCanvasSize(Printer.Canvas, 3.0, 2.5, 0.5);
181 BarCode1.SupplementalCode := '12345';
182 BarCode1.PaintToCanvasSize(Printer.Canvas, 6.0, 2.5, 0.5);
183
184 BarCode1.BarcodeType := bcEAN_8;
185 BarCode1.Code := '1234567';
186 BarCode1.SupplementalCode := '';
187 BarCode1.PaintToCanvasSize(Printer.Canvas, 0.5, 3.5, 0.5);
188 BarCode1.SupplementalCode := '12';
189 BarCode1.PaintToCanvasSize(Printer.Canvas, 3.0, 3.5, 0.5);
190 BarCode1.SupplementalCode := '12345';
191 BarCode1.PaintToCanvasSize(Printer.Canvas, 6.0, 3.5, 0.5);
192
193 BarCode2.BarcodeType := bcInterleaved2of5;
194 BarCode2.Code := '0123456789';
195 BarCode2.PaintToCanvasSize(Printer.Canvas, 0.5, 4.5, 0.5);
196
197 BarCode3.BarCodeType := bcCodabar;
198 BarCode3.Code := 'c1234567890d';
199 BarCode3.PaintToCanvasSize(Printer.Canvas, 3.0, 4.5, 0.5);
200
201 BarCode4.BarCodeType := bcCode11;
202 BarCode4.Code := '0123456-12';
203 BarCode4.PaintToCanvasSize(Printer.Canvas, 5.0, 4.5, 0.5);
204
205 BarCode5.BarCodeType := bcCode39;
206 BarCode5.Code := '1234567890ABCDEFG';
207 BarCode5.PaintToCanvasSize(Printer.Canvas, 0.5, 5.5, 0.5);
208 BarCode5.Code := '4-976 SUGARLOAF HWY';
209 BarCode5.PaintToCanvasSize(Printer.Canvas, 4.5, 5.5, 0.5);
210
211 BarCode6.BarCodeType := bcCode93;
212 BarCode6.Code := 'CODE 93';
213 BarCode6.PaintToCanvasSize(Printer.Canvas, 0.5, 6.5, 0.5);
214
215 BarCode7.BarCodeType := bcCode128;
216 BarCode7.Code128Subset := csCodeA;
217 BarCode7.Code := 'CODE 128';
218 BarCode7.Validate(True);
219 BarCode7.PaintToCanvasSize(Printer.Canvas, 3.0, 6.5, 0.5);
220
221 StMaxiCodeBarcode1.Mode := cmMode5;
222 StMaxiCodeBarcode1.Code := 'MaxiCode';
223 StMaxiCodeBarcode1.Caption := 'MaxiCode';
224 StMaxiCodeBarcode1.PaintToPrinterCanvasSize (Printer.Canvas, 0.5, 7.5, 1);
225
226 StPDF417Barcode1.Code := 'PDF417';
227 StPDF417Barcode1.Caption := 'PDF417';
228 StPDF417Barcode1.PaintToPrinterCanvasSize (Printer.Canvas, 3.0, 7.5, 1);
229 finally
230 if not Printer.Aborted then
231 Printer.EndDoc;
232 end;
233 finally
234 Screen.Cursor := crDefault;
235 end;
236 end;
237
238 procedure TBarCodeForm.btnCopyClick(Sender: TObject);
239 begin
240 case NB.PageIndex of
241 0 : BarCode1.CopyToClipboard;
242 1 : BarCode2.CopyToClipboard;
243 2 : BarCode3.CopyToClipboard;
244 3 : BarCode4.CopyToClipboard;
245 4 : BarCode5.CopyToClipboard;
246 5 : BarCode6.CopyToClipboard;
247 6 : BarCode7.CopyToClipboard;
248 7 : StPDF417Barcode1.CopyToClipboard;
249 8 : StMaxiCodeBarcode1.CopyToClipboard;
250 end;
251 end;
252
253 procedure TBarCodeForm.btnValidateClick(Sender: TObject);
254 begin
255 case NB.PageIndex of
256 0 : BarCode1.Validate(True);
257 1 : BarCode2.Validate(True);
258 2 : BarCode3.Validate(True);
259 3 : BarCode4.Validate(True);
260 4 : BarCode5.Validate(True);
261 5 : BarCode6.Validate(True);
262 6 : BarCode7.Validate(True);
263 end;
264 end;
265
266 procedure TBarCodeForm.btnCloseClick(Sender: TObject);
267 begin
268 Close;
269 end;
270
271 procedure TBarCodeForm.btnSaveClick(Sender: TObject);
272 begin
273 case NB.PageIndex of
274 0 : BarCode1.SaveToFile('UPCEAN.bmp');
275 1 : BarCode2.SaveToFile('I2of5.bmp');
276 2 : BarCode3.SaveToFile('Codabar.bmp');
277 3 : BarCode4.SaveToFile('Code11.bmp');
278 4 : BarCode5.SaveToFile('Code39.bmp');
279 5 : BarCode6.SaveToFile('Code93.bmp');
280 6 : BarCode7.SaveToFile('Code128.bmp');
281 7 : StPDF417Barcode1.SaveToFile ('PDF417.bmp');
282 8 : StMaxiCodeBarcode1.SaveToFile ('MaxiCode.bmp');
283 end;
284 end;
285
286 procedure TBarCodeForm.btnUpdate1Click(Sender: TObject);
287 begin
288 case rgType.ItemIndex of
289 0 : begin
290 BarCode1.BarcodeType := bcUPC_A;
291 edCode1.MaxLength := 12;
292 edCode1.Text := Copy(edCode1.Text, 1, 12);
293 Label1.Caption := 'Code: 11 or 12 Numeric ';
294 end;
295 1 : begin
296 BarCode1.BarcodeType := bcUPC_E;
297 edCode1.MaxLength := 6;
298 Label1.Caption := 'Code: 6 Numeric ';
299 edCode1.Text := Copy(edCode1.Text, 1, 6);
300 end;
301 2 : begin
302 BarCode1.BarcodeType := bcEAN_13;
303 edCode1.MaxLength := 13;
304 Label1.Caption := 'Code: 12 or 13 Numeric ';
305 edCode1.Text := Copy(edCode1.Text, 1, 13);
306 end;
307 3 : begin
308 BarCode1.BarcodeType := bcEAN_8;
309 edCode1.MaxLength := 8;
310 Label1.Caption := 'Code: 7 or 8 Numeric ';
311 edCode1.Text := Copy(edCode1.Text, 1, 8);
312 end;
313 end;
314 BarCode1.ShowCode := cbShowCode.Checked;
315 BarCode1.TallGuardBars := cbTallGuardBars.Checked;
316 BarCode1.Code := edCode1.Text;
317 if cbSupp.Checked then begin
318 BarCode1.SupplementalCode := edSupp.Text;
319 edSupp.Enabled := True;
320 end else begin
321 BarCode1.SupplementalCode := '';
322 edSupp.Enabled := False;
323 end;
324 end;
325
326 procedure TBarCodeForm.btnUpdate2Click(Sender: TObject);
327 begin
328 BarCode2.Code := edCode2.Text;
329 BarCode2.ShowCode := cbShowCode2.Checked;
330 BarCode2.BearerBars := cbBearerBars.Checked;
331 end;
332
333 procedure TBarCodeForm.btnUpdate3Click(Sender: TObject);
334 begin
335 BarCode3.Code := edCode3.Text;
336 BarCode3.ShowCode := cbShowCode3.Checked;
337 BarCode3.ShowGuardChars := cbShowGuardChars3.Checked;
338 end;
339
340 procedure TBarCodeForm.btnUpdate4Click(Sender: TObject);
341 begin
342 BarCode4.Code := edCode4.Text;
343 BarCode4.ShowCode := cbShowCode4.Checked;
344 end;
345
346 procedure TBarCodeForm.btnUpdate5Click(Sender: TObject);
347 begin
348 BarCode5.Code := edCode5.Text;
349 BarCode5.ShowCode := cbShowCode5.Checked;
350 end;
351
352 procedure TBarCodeForm.btnUpdate6Click(Sender: TObject);
353 begin
354 BarCode6.Code := edCode6.Text;
355 BarCode6.ShowCode := cbShowCode6.Checked;
356 end;
357
358 procedure TBarCodeForm.btnUpdate7Click(Sender: TObject);
359 begin
360 BarCode7.Code := edCode7.Text;
361 BarCode7.ShowCode := cbShowCode7.Checked;
362 end;
363
364 procedure TBarCodeForm.btnUpdatePDF417Click(Sender: TObject);
365 begin
366 StPDF417Barcode1.Truncated := cbPDF417Truncated.Checked;
367 StPDF417BarCode1.Code := edCodePDF417.Text;
368 if cbShowCodePDF417.Checked then
369 StPDF417BarCode1.Caption := edCodePDF417.Text
370 else
371 StPDF417BarCode1.Caption := '';
372 end;
373
374 procedure TBarCodeForm.btnUpdateMaxiCodeClick(Sender: TObject);
375 begin
376 StMaxiCodeBarCode1.Code := edCodeMaxiCode.Text;
377 StMaxiCodeBarCode1.CarrierCountryCode := StrToInt (edMCCountryCode.Text);
378 StMaxiCodeBarCode1.CarrierPostalCode := edMCPostalCode.Text;
379 StMaxiCodeBarCode1.CarrierServiceClass := StrToInt (edMCServiceClass.Text);
380 if cbShowCodeMaxiCode.Checked then
381 StMaxiCodeBarCode1.Caption := edCodeMaxiCode.Text
382 else
383 StMaxiCodeBarCode1.Caption := '';
384 end;
385
386 procedure TBarCodeForm.radMCMode4Click(Sender: TObject);
387 begin
388 edMCServiceClass.Enabled := False;
389 edMCPostalCode.Enabled := False;
390 edMCCountryCode.Enabled := False;
391 StMaxiCodeBarCode1.Mode := cmMode4;
392 btnUpdateMaxiCodeClick (Sender);
393 end;
394
395 procedure TBarCodeForm.radMCMode23Click(Sender: TObject);
396 begin
397 edMCServiceClass.Enabled := True;
398 edMCPostalCode.Enabled := True;
399 edMCCountryCode.Enabled := True;
400 StMaxiCodeBarCode1.Mode := cmMode2;
401 btnUpdateMaxiCodeClick (Sender);
402 end;
403
404 procedure TBarCodeForm.radMCMode5Click(Sender: TObject);
405 begin
406 edMCServiceClass.Enabled := False;
407 edMCPostalCode.Enabled := False;
408 edMCCountryCode.Enabled := False;
409 StMaxiCodeBarCode1.Mode := cmMode5;
410 btnUpdateMaxiCodeClick (Sender);
411 end;
412
413 procedure TBarCodeForm.NBChange(Sender: TObject; NewTab: Integer;
414 var AllowChange: Boolean);
415 begin
416 if (NewTab = 7) or (NewTab = 8) then
417 btnValidate.Enabled := False
418 else
419 btnValidate.Enabled := True;
420 end;
421
422 end.
423
424
425

  ViewVC Help
Powered by ViewVC 1.1.20