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

Contents of /dao/DelphiScanner/Components/tpsystools_4.04/examples/Delphi/expnbaru.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: 3029 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 (******************************************************************************
27
28 Enter a five-digit zip code and the inches to print from the left and top of
29 the page or envelope. Don't forget that laser printers can't print all the
30 way to the edge and so the value you enter must be adjusted accordingly. For
31 example, if you enter 5.0 for the "From Left" value and the printer has a
32 1/4" non-printable border, the bar code will be located 5.25" from the
33 actual edge of the paper.
34
35 NOTE: Be sure to change the constant PrinterPixPerInch to match the
36 resolution of your printer.
37
38 *******************************************************************************)
39
40 unit expnbaru;
41
42 interface
43
44 uses
45 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
46 StdCtrls, Mask,
47
48 StBarPN;
49
50 const
51 PrinterPixPerInch = 600;
52
53 type
54 TfrmPostNet = class(TForm)
55 btnPrint: TButton;
56 meLeft: TMaskEdit;
57 Label1: TLabel;
58 Label2: TLabel;
59 meTop: TMaskEdit;
60 BarCode1: TStPNBarCode;
61 meZIP: TMaskEdit;
62 Label3: TLabel;
63 procedure FormCreate(Sender: TObject);
64 procedure btnPrintClick(Sender: TObject);
65 procedure meZIPChange(Sender: TObject);
66 private
67 { Private declarations }
68 public
69 { Public declarations }
70 end;
71
72 var
73 frmPostNet: TfrmPostNet;
74
75 implementation
76
77 {$R *.DFM}
78
79 uses
80 Printers,
81 StStrS;
82
83 procedure TfrmPostNet.FormCreate(Sender: TObject);
84 begin
85 meZIP.Text := BarCode1.PostalCode;
86 meLeft.Text := ' 5' + DecimalSeparator + '0';
87 meTop.Text := ' 3' + DecimalSeparator + '9';
88 end;
89
90 procedure TfrmPostNet.btnPrintClick(Sender: TObject);
91 var
92 P : TPoint;
93 L,
94 T : longint;
95 begin
96 L := Round(StrToFloat(meLeft.Text) * PrinterPixPerInch);
97 T := Round(StrToFloat(meTop.Text) * PrinterPixPerInch);
98 P := Point(L, T);
99 Printer.BeginDoc;
100 BarCode1.PaintToPrinterCanvas(Printer.Canvas, P);
101 Printer.EndDoc;
102 end;
103
104 procedure TfrmPostNet.meZIPChange(Sender: TObject);
105 var
106 S : ShortString;
107 begin
108 S := TrimS(meZIP.Text);
109 if (Length(S) = 5) then
110 BarCode1.PostalCode := meZIP.Text;
111 end;
112
113 end.

  ViewVC Help
Powered by ViewVC 1.1.20