A single Delphi Form may contain any number of Active Barcode Components. The first to be added will be called Axbarcode1, the second Axbarcode2, and so on; the names may be changed by the user by modifying the Name property within the Delphi Object Inspector.
Each component added will be visible on the form. You may wish to use this image of the component. Alternatively you may hide the component (by setting its Visible property to false) and use the components methods and properties to create an image that is copied elsewhere on the form.
The principal steps involved in using a barcode image within Delphi are as follows:
1. Set those properties which Active Barcode Component requires to generate the barcode, the minimum of which are
Axbarcode1.CodeType
- specifies the barcode type required
Axbarcode1.Caption - specifies
the characters which make up the code
2. Allow the component's image to be displayed on the form (if required).
3. Printing the Barcode on the Printer
To print the barcode image on the printer StretchDraw the picture graphic to the Printer object, again using the PictureHeight and PictureWidth parameters to scale the picture to the Printer's canvas, eg.
{set the target rectangle
for drawing on the printer}
{change from mm to
pixels}
ii:=(Axbarcode1. PictureWidth*pScalex)
div 100;
jj:=(Axbarcode1.
PictureHeight*pScaley) div 100;
Rect.Left:=200;
Rect.Top:=200;
Rect.Right:=Rect.Left+ii;
Rect.Bottom:=Rect.Top+jj;
Printer.BeginDoc;
Printer.Canvas.StretchDraw(Rect,
Axbarcode1.Picture.Graphic);
Printer.EndDoc;
where pScalex and pScaley are for converting the picture units to printer pixels.
More: