Using the component within C++Builder

A single Builder 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 user may change the names by modifying the Name property within the Builder 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, which is copied elsewhere on the form.

 

The principal steps involved in using a barcode image within Builder 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
    Prntr = Printer();
    i=GetDeviceCaps((Prntr->Handle),LOGPIXELSX);
    pScalex=(1000*i) / 254; //100 * pixels per mm
    i=GetDeviceCaps((Prntr->Handle),LOGPIXELSY);
    pScaley=(1000*i) / 254; //100 * pixels per mm
    ft=AxbarcodeProxy1->PictureWidth;
    ii=int((ft*pScalex)/ 100.0);
    ft=AxbarcodeProxy1->PictureHeight;
    jj=int((ft*pScaley) /100.0);
    Rect.Left=200;
    Rect.Top=200;
    Rect.Right=Rect.Left+ii;
    Rect.Bottom=Rect.Top+jj;
    Prntr->BeginDoc();
    Prntr->Canvas->StretchDraw(Rect, AxbarcodeProxy1->Picture->Graphic);
    Prntr->EndDoc();

where pScalex and pScaley are for converting the picture units to printer pixels.

 

More:

Using Active Barcode Components in a Container