![]()
Quick_links...
Search site
Trial products
Online tutorials
Products
Barcodes for Office
Barcode creators
Barcode fonts
Developer tools
Label printing
Labelling tools
Windows Phone
Resources
New to barcodes?
How To ...
Support centre
Tutorial centre
Which product
For users
Common problems
What's New?
Newsletter
Online registration
Contact us



For creating barcodes in the Delphi environment the component available for use with the dBarcode DLLs is ideal. The components are derived from TImage and so offer all the flexibility of the native component.
Screenshot - click to enlarge
The Tbarcodenn class is provided as source code is provided in a PAS file.
The component may be installed by installing the component as a PAS file and compiling the resulting user library.
The component’s icon (which is a TImage icon) will appear in the Samples page of the available components.
The barcode component is based on the TImage and so inherits many of its properties from this object. Over and above this, the component supports properties specific to its application, in this case the production of Barcodes. The component can be placed on a form and its properties set a Design time or altered through code at Run-Time.
A sample application is included with each product in the form of the dBarcode1 project, which includes the UNIT1.PAS source file. A typical example is shown below
To print a barcode image one approach is to Draw the Picture on the Printer.Canvas, as shown in the code sample below.
Note that the Picture is created in HIMETRIC units, and so to print the image at the correct size these must be converted into printer pixel units using the GetDeviceCaps() function.
procedure
TForm1.Button2Click(Sender: TObject);
var
ii: integer;
jj:
integer;
Rect: TRect;
pScalex: Integer;
pScaley: integer;
begin
DoBarcode(); {recreate the barcode image}
{set the target rectangle for drawing on the printer}
{change from mm to pixels}
pScalex:=GetDeviceCaps((Printer.Handle),LOGPIXELSX);
pScaley:=GetDeviceCaps((Printer.Handle),LOGPIXELSY);
ii:=(Barcode1.ImageWidth*pScalex) div 2540;
jj:=(Barcode1.ImageHeight*pScaley) div 2540;
Rect.Left:=200;
Rect.Top:=200;
Rect.Right:=Rect.Left+ii;
Rect.Bottom:=Rect.Top+jj;
Printer.BeginDoc;
Printer.Canvas.StretchDraw(Rect, Barcode1.Picture.Graphic);
Printer.EndDoc;
end;