Introduction

Active Barcode Components (version 7) are Active-X/Automation Controls that allow barcode images to be created within the user’s own software. A barcode image may be displayed on screen, printed on a printer, saved to a disk file, or passed to the Windows clipboard for incorporation into another Windows application.

Although primarily designed for Microsoft's Visual Basic 6 and Visual Basic for Applications (VBA), Active-Barcode Components may be employed with other Active-X-enabled systems, such as the Visual Studio or Delphi development environments. Examples provided in this manual are based on Visual Basic 6, Visual Studio 2005 or later, and Office 2003 or later.

Users should note that the encoding calculations are performed when the component’s image is created, by being used, accessed or copied. Information properties (such as PictureWidth) are not available until the image has been created.

The current release includes 32 bit and 64 bit components. Both components are fully Unicode compatible. The 64 bit component cannot be used on a 32 bit system. The source code sample provided for the 64 bit component is a Visual Studio 2005 WinForms application.

Active Barcode Components are available either as the Universal package, which includes 1D and 2D controls that may be licenced separately, or as individual controls for specific groupd of 1D or 2D barcodes.

More:

The Universal controls

The 1D controls

The 2D controls

Registering the control


The Universal controls

Active Barcode Component Universal
This package contains two controls which may be installed/licenced separately:

Axbarcode.ocx – for most common 1D barcode types (over 60 types supported; see the Barcodes HELP file for the complete list).

A2barcode.ocx – for Aztec, Databar, Datamatrix, Maxicode, PDF417 and QR Code symbols. .

More:

The 1D controls


The 1D controls

There are two 1D controls in the Active Barcode Components (version 7) family, one for common industrial barcodes and one for common retail barcode types. The controls are:

Active Barcode Component Code Standard
Abc39.ocx – for Code 39, Extended Code 39, Code 93, Extended Code 93, Code 128, Interleaved 2 of 5 and Matrix 2 of 5 barcodes

Active Barcode Component GS1
AbcEAN.ocx – for EAN-13, EAN-14, EAN-8, UPC-A, UPC-E, ISBN, ISSN, ISMN, GS1-128 and ITF-14 and SSCC (Serial Shipping Container Code) barcodes

With the exception of the CodeType property (which specifies the type of barcode to be generated) all controls share the same control properties, and in this manual all control are discussed using the name of the Active Barcode Control Universal 1D component. The values of the CodeType property for the individual controls is described under Properties.

More:

The 2D controls


The 2D controls

There are several 2D barcode controls in the Active Barcode Components family, one for each of the most popular 2D barcode types. The controls are:

Active Barcode Component Aztec
AbcAZT.ocx – for Aztec barcodes

Active Barcode Component Databar
AbcRSS.ocx – for Databar (formerly RSS) barcodes

Active Barcode Component DataMatrix
AbcDMAT.ocx – for square and rectangular DataMatrix barcodes

Active Barcode Component PDF417
AbcPDF.ocx – for PDF417 and Micro-PDF417 barcodes

Active Barcode Component QR
AbcQR.ocx – for QR Code barcodes

More:

Registering the control


Registering the control

Before an Active-X component may be used within a particular Windows installation it must be registered with the Windows System Registry. The Setup program that installs the product on your system provides automatic one-time registration. However, if you use the component on another system registration may NOT be automatic. Many container applications (Visual Basic, MS Office, etc.) offer facilities to register components by displaying a dialog and browsing for the component's file - axbarcode.ocx. As a last resort, the component may be registered manually be executing the following commands from within a command prompt:

To register the component

C:\path\regsvr32.exe C:\path\AXBARCODE.OCX.

Similarly the component may be un-registered using:

C:\path\regsvr32.exe C:\path\AXBARCODE.OCX -u.

If the component is moved or upgraded ir must be re-registered.

Once registered the component may be used within Visual Basic 6 (and other environments). The Active Barcode Component may be included on Visual Basic's Toolbar by checking the

dLSoft 1D Barcode control

entry in the Custom Controls dialog accessible on the Tools menu. The OCX then appears as an icon on the toolbar.

Note that regsvr32.exe is used to register 32 bit or 64 bit components.

More:

Using with CreateObject


Using with CreateObject

While the components can be added to applications at design-time (as described in the sections that follow) they may also be created at run-time using CreateObject.

A simple example is shown here for a VB6 application consisting of a form containing a PictureBox:

Public abc As Object

Private Sub Form_Load()
Set abc = CreateObject("A2BARCODE.A2barcodeCtrl.4")
abc.CodeType = 1
abc.Xunit = 20
abc.Caption = "Hello World"
Picture1.Picture = abc.Picture
End Sub

When the form loads the abc object is created, some of its properties are specified, then the resulting barcode picture is placed in the PictureBox Picture1.

The string in the CreateObject function is the Class name of the component. The Table below shows the class names for the Active Barcode Component classes.

Active Barcode component Universal (2D) | A2BARCODE.A2barcodeCtrl.4
Active Barcode component Universal (1D) | Axbarcode.Control.4
Active Barcode component Aztec | ABCAZT.AbcaztCtrl.4
Active Barcode component Databar | ABCRSS.AbcrssCtrl.4
Active Barcode component Datamatrix | ABCDMAT.AbcdmatCtrl.4
Active Barcode component PDF417 | ABCPDF.AbcpdfCtrl.4
Active Barcode component QR Code | ABCQR.AbcqrCtrl.4
Active Barcode component Standard | ABC39.Abc39Ctrl.4
Active Barcode component GS1 | ABCEAN.AbceanCtrl.4

Objects created this way may have their properties set in code or by providing a call to one of the components methods, such as

Abc.ShowProps

More:

Distributing Programs using Active Barcode Component


Distributing Programs using Active Barcode Component

Any program using one of the Active Barcode Components must have access to the component in OCX file (e.g. AXBARCODE.OCX). No other files are required by the control, although the target computer must has a suitable version of the operating system's OLE system files installed (OLEAUT32.DLL on Windows XP). Any OLE enabled software, such as Microsoft Office, will have installed these files.

Single user versions of these products are licensed for use only on a single computer.

Developer versions of the OCX run-time file (e.g. AXBARCODE.OCX) may be distributed Royalty-free for up to 10,000 copies. The Design time licence may NOT be distributed.

More:

Using in VB6 and .NET


Using in VB6 and .NET

More:

Adding the control to a Visual Basic form

VB.NET and C#

Setting and retrieving property values

Creating a barcode Picture within a program


Adding the control to a Visual Basic form

To add an Active Barcode Component control to a Visual Basic 6 form, select Components from the VB Project menu. If dLSoft 1D Barcode control module is displayed in the list of available controls, then ensure that it is checked. If it does not appear in the list user the Browse button to locate it in its installation directory (or in Windows System or System32), then check its name in the list. Once checked, an icon representing the component will appear in the toolbox.

The controls appear in the list of available controls as follows:

Active Barcode Component | control name
Universal 1D component | dLSoft Barcode 1D control
Standard | dLSoft Barcode Std control
GS1 | dLSoft Barcode GS1 control
Aztex | dLSoft Aztec control
Datamatrix | dLSoft Datamatrix control
Databar | dLSoft Databar control
Maxicode | dLSoft Maxicode control
PDF417 | dLSoft PDF417 control
QR Code | dLSoft QR Code control
Universal 2D component | dLSoft Barcode 2D control

Clicking on the Active Barcode Component’s icon in the toolbox causes the cursor to change to a cross. Positioning the cross on a Visual Basic form, holding down the left mouse button and dragging the cursor down and to the left, then releasing the mouse button, causes a rectangle to be drawn on the form. An image of a (default) barcode will be shown within this rectangle. 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 placed elsewhere on the form - as in the sample Visual Basic program that is supplied with the component and uses code of the form:

Axbarcode1.ImageHeight = i
Axbarcode1.ImageWidth = j
Axbarcode1.Xunit = 0
Axbarcode1.CodeType = type
Axbarcode1.Caption = Text
Image1.Picture = Axbarcode1.Picture

A single Visual Basic 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 Visual Basic Properties box.

Alternatively an array of controls may be created using the Index property.

More:

VB.NET and C#


VB.NET and C#

The control may be added to the Visual Studio.NET Toolbox by right clicking on the Toolbox and selecting Customise Toolbox from the pop-up menu displayed, then checking the control in the list presented. The control will then appear as an icon on the Toolbox. For new applications we recommend the dBarcode.NET components which are managed code components specifically designed for use with .NET and considerably more efficient in that environment than active-X controls.

More:

Setting and retrieving property values


Setting and retrieving property values

The Active Barcode Component may be operated entirely by setting or retrieving Property values using the Basic language.

Clicking on the Active Barcode Component control on the form when VB's Properties box is displayed will show the current settings for component's available properties. Most of these may be edited using the Properties box, or may have their values set from within the user's program by statements of the kind

Axbarcode1.Source="12345"

Active Barcode Component properties that are set AFTER a Picture is created may be retrieved within user's programs by statements of the kind:

x=Axbarcode1.ErrorCode

More:

Creating a barcode Picture within a program


Creating a barcode Picture within a program

Active Barcode Component produces its barcode image as a Windows metafile. This metafile is displayed directly in the area you create for the component - unless you set the Axbarcode.Visible property to FALSE.

To create a printable Picture object containing the barcode within a program the following steps are required:

1. Set those properties that 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).

OR

Copy the components Picture property to an image on the form, eg.

If Axbarcode1.ErrorCode = 0 Then
Image1.Picture = Axbarcode1.Picture

3. Printing the Barcode on the Printer

To print the barcode image on the printer use the PaintPicture method of the Printer object, eg.

Printer.ScaleMode = 6 ' sets printer scale to mm

Printer.PaintPicture Axbarcode1.Picture, 20, 20, Axbarcode1.PictureWidth, Axbarcode1.PictureHeight

Printer.NewPage

Printer.EndDoc

4. Printing from VB.NET or C#

Printing from Managed code is accomplished using the PrintDocument control from the Visual Studio.NET ToolBox. Add the control to your application, then use it as illustrated below; in this example only the barcode image is printed.

Private Sub print1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles print1.Click
Try
AddHandler PrintDocument1.PrintPage, AddressOf Me.PrintDocument1_PrintPage
PrintDocument1.Print()
Catch ex As Exception
MessageBox.Show("An error occurred while printing", _
ex.ToString())
End Try
End Sub

Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
Dim newImage As Image = Axbarcode1.Picture
Dim x As Integer
Dim y As Integer
x = Axbarcode1.PictureWidth ' in mm
y = Axbarcode1.PictureHeight ' in mm

Dim ulCorner As New Point(50, 50) ‘ set position on page
Dim urCorner As New Point(x + 50, 50)
Dim llCorner As New Point(50, 50 + y)
Dim destPara As Point() = {ulCorner, urCorner, llCorner}
e.Graphics.PageUnit = GraphicsUnit.Millimeter
e.Graphics.DrawImage(newImage, destPara)
' Indicate that this is the last page to print.
e.HasMorePages = False
End Sub

More:

Using in Delphi


Using in Delphi

Active Barcode Components (like most Active-X controls) can be used within Delphi, but dLSoft recommends the dBarcode DLLs for use with Delphi as these products include Delphi Components derived from TImage.

More:

Importing the component into a Delphi Development System

Using the component within Delphi


Importing the component into a Delphi Development System

To start using the Active Barcode Component in the Delphi IDE follow these steps:

From Delphi's Component menu choose Import ActiveX Control

Select dLSoft 1D Barcode control from the list of installed controls.

Push the Install button. You can then choose to import the control into an existing package, or create a new package.

When installation has finished, the Active Barcode Component icon will be available from the ActiveX toolbar.

To place the package on a Delphi form simply select the Active Barcode Component icon from the ActiveX toolbar and use the cursor to draw a position for it on the form. The Taxbarcode object is then available for use.

More:

Using the component within Delphi


Using the component within Delphi

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:

Using in C++ Builder


Using in C++ Builder

More:

Importing into a C++ Builder Development System

Using the component within C++Builder


Importing into a C++ Builder Development System

To start using the Active Barcode Component in the C++ Builder IDE follow these steps:

1. From Builder's Component menu choose Import ActiveX Control

2. Select dLSoft 1D Barcode control from the list of installed controls.

3. Push the Install button. You can then choose to import the control into an existing package, or create a new package.

4. When installation has finished, the Active Barcode Component icon will be available from the ActiveX toolbar.

To place the package on a Builder form simply select the Active Barcode Component icon from the ActiveX toolbar and use the cursor to draw a position for it on the form. The Taxbarcode object is then available for use.

More:

Using the component within C++Builder


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 in a Container


Using in a Container

Active Barcode Components may be inserted into Container programs (such as Word) generally by selecting Insert Object from the EDIT or INSERT menus and choosing dLSoft 1D Barcode control from the list of options presented.

The properties of the barcode image may be set by selecting the barcode and right-clicking on it and choosing Properties from the pop-up menu displayed, either double-clicking on it; alternatively by summoning its Property Pages dialog from the Edit – dLSoft 1D Barcode control Object menu item.

The Property Pages dialog provides a tabbed dialog box containing three pages.

The General Page provides the user with the opportunity to set the Codetype, the Code value (the Caption), and the target height and width. Checkboxes are provided to allow the Nominal size to be specified (valid only for barcodes which have a nominal size), and for the check digit to be calculated automatically (for those codes which have check digits. An X unit box allows the width of the barcode to be calculated by the control, using the X unit size The X unit is the width of the thinnest bar (in mils - 0.001 inches, not mm). If X is provided as 0 then the width of the barcode is determined by the content of the width box.

Details of the properties are given in the Reference section.

The Options page enables most of the remaining properties to be specified, either through checkboxes or by specifying numerical values in the edit boxes.

The Font/Colours page allows the foreground (bars and text) colour and the background colour to be selected from the system colours available, and the Font properties (for text under the barcode image) to be selected from the normal Windows Font dialog

.

Note that the size of the font selected will be correctly reproduced only when the metafile is displayed at the size specified in the target height and width boxes on the Code page. The metafiles image created if fully resizable, so changing the size of the barcode image will also change the actual size of the font used for the text.

Each Property page contains an OK button which, if pushed causes the current contents of all the pages to be used in re-creating the barcode image. The pages also contain a Cancel button that may be used to close the Property pages dialog and discard any changes made.

More:

Using in Access


Using in Access

Microsoft Access is a database that holds data in tables. When an Active Barcode Component is added to an Access Form or Report as an ActiveX control, the component's Properties list allows the user to select one of the Table fields as a Source of the components data - ie the data to appear in the barcode.

The Record Source may be selected from a drop-down list in the form or report's properties list, and the barcode's Control Source may be selected from the drop down list in the component's properties list. All other properties (code type, size, font, etc.) can be selected from the other entries in the Access Properties list at design time.

This allows barcode creation to be fully automatic for every record in a database.

Of course, a barcode image that is the same on every record may also be created - by ensuring that the Control Source entry on the component's properties list is empty, and the required data is entered for the Caption property.

A sample Access database is included with the distribution

Active Barcode Component properties for a barcode image on a form or report may also be set at run-time using Visual Basic module code to modify the control's properties.

More:

Using in Word


Using in Word

There are two different ways of using the Active Barcode Component within Microsoft Word.

1. The component may be inserted as an Object - by choosing Object from the Insert menu, or

2. The component may be added as an ActiveX control from the Control Toolbox.

The component behaves in rather different ways in these two cases.

When inserted as an object the component behaves in just the same way as when inserted into any other container. Right-clicking on the barcode image and selecting Properties from the pop-up menu brings up the property pages that allow the barcode properties to be specified. (See Using Active Barcode Component in a Container for details.)

When added as an ActiveX Control the component is programmable from within Word's Visual Basic Editor. A number of simple macros are included in the ABC1.DOC sample supplied with Active 2D Barcode Component. While the sample macros are run from the Tools - Macros menu, single keystroke shortcuts can be added by choosing Tools - Customise and then pushing the Keyboard button. Scroll the categories list down to Macros and then choose a key to be used to initiate each macro. That's all there is to it.

Of course the macros supplied are rather rudimentary. Almost anything can be done by setting properties and calling methods.

More:

Setting the image size


Setting the image size

Active Barcode Components creates a barcode image at a size specified by the user – either using the ImageHeight and ImageWidth properties, or using the ImageHeight and Xunit properties. However, the metafile image is fully resizeable by the user - so can be displayed or printed at a size other than that originally created.

There are three ways of specifying the size at which the image is created:

1. For a limited number of barcode types there is a Nominal size (ie. A size specified by the standards body responsible for that barcode type). EAN, GS1, UPC and ITF barcodes have nominal sizes. In general it is recommended that these barcode types be reproduced either at the nominal size or within a fairly narrow range of sizes around nominal (typically 80 - 120% of nominal). These barcode types may have their size specified by setting the NominalSize property. After the image has been created the PictureWidth and PictureHeight properties contain the actual width and height of the barcode image.

2. Any barcode type may have the image size specified by setting the xunit property to the width of the narrowest element in the barcode (narrowbar) when the NominalSize property is set to 0. Xunit values are specified in Mils. In this case the initial setting of the ImageWidth property is ignored. After the image has been created the PictureWidth and PictureHeight properties contain the actual width and height of the barcode picture.

3. Any barcode type may have the image size specified by setting the ImageWidth and ImageHeight properties when the NominalSize property is set to 0 and the xunit property is set to 0.

More:

A Note on Metafile pictures


A Note on Metafile pictures

The picture images placed on the clipboard by dLSoft's Active Barcode Component's CopyImage method are ANISOTROPIC metafiles. This means that they can be resized within applications (usually by dragging a corner).

While the barcode bars can be resized over very wide ranges, any text included within the image may not resize as expected. In general changing the height of the image by resizing within another application will change the fontsize used to render the text. Changing the width of the image within another application may cause the position of any text under the barcode to change.

The use of TrueType fonts is recommended to prevent unusual effects caused by resizing of text. Furthermore, the use of Enhanced Metafiles has the advantage of producing images in which the fonts scale more smoothly than they do in standard metafiles.

The CopyImage method produces both standard metafile and enhanced metafile pictures on the clipboard. In most case an application that is to receive the picture by pasting will choose the most appropriate picture.

The SaveImage method (when used with a wmf file extension) produces a standard metafile image.

More:

1D Component Reference


1D Component Reference

More:

Summary of Properties and Methods

Required properties

Information properties

Methods

Events


Summary of Properties and Methods

Active Barcode Component properties fall into two categories - those that are required to specify characteristics of the barcode image, and those that provide information about the barcode.

The most important properties and methods are outlined below, and followed by sections in which the properties and methods are defined in detail.

More:

Component properties.

Methods of using the barcode image


Component properties.

The properties that can be set to generate an image

Axbarcode1.AutoParity specifies whether any check digits are calculated automatically

Axbarcode1.BackColor the colour behind the bars

Axbarcode1.BarRatio specifies the ratio of wide/narrow bar (times ten) for some barcode types

Axbarcode1.BarReduce specifies the percentage reduction in bar thickness (useful for allowing for ink spread in wet-ink printing processes.

Axbarcode1.BearerBarThickness specifies the thickness of bearer bars for those barcodes that may have bearer bars

Axbarcode1.BorderSize specifies the thickness of any border around the image (in points)

Axbarcode1.Caption specifies the characters that make up the code

Axbarcode1.CharSpacing the percentage of the barcode width over which the text under the barcode should be spread out.

Axbarcode1.CodeType specifies the barcode type required

Axbarcode1.ExtendBearers Allows bearer bars to extend into light margins.

Axbarcode1.ForeColor the colour of the bars and any text under the bars

Axbarcode1.Font The font used to render any text under the barcode

Axbarcode1.FontSize, FontName, FontBold, FontItalic are alternative ways of specifying font characteristics

Axbarcode1.ImageHeight required target height of barcode image (in units determined by the setting of ScaleMode)

Axbarcode1.ImageWidth required target width of barcode image (in units determined by the setting of ScaleMode)

Axbarcode1.JustifyText specifies the text justification for human readable text under the barcode

Axbarcode1.MarginSize specifies the size of the light margins

Axbarcode1.NominalSize specifies a percentage of the barcode's standard size at which the image should be created. If specified the calculated value overrides the ImageHeight and ImageWidth parameters.

Axbarcode1.Orientation specifies the orientation of the barcode image

Axbarcode1.PictureHeight the height of barcode picture generated (in units determined by the setting of ScaleMode)

Axbarcode1.PictureWidth the width of barcode picture generated (in units determined by the setting of ScaleMode)

Axbarcode1.ScaleMode specifies the units of ImageHeight and ImageWidth and PictureHeight and PictureWidth parameters (default is 6 = mm)

Axbarcode1.ShowBearerBars determines whether (or how many) bearer bars are displayed

Axbarcode1.ShowText specifies that the text content of the barcode should be displayed under the bars

Axbarcode.ShowCheckDigit specifies whether any automatic check digit is displayed (for those barcode type which permit this)

Axbarcode1.ShowLightMargin specifies whether light margin indicators should be displayed for those barcode types that support these

Axbarcode1.TargetHdpi Target device horizontal resolution (in dpi) for bitmap based images

Axbarcode1.TargetVdpi Target device vertical resolution (in dpi) for bitmap based images

Axbarcode1.xunit specifies the thickness of each barcode element in mils

Many of these properties have default values (see the reference section), so do not require changing if you can make do with the default values. The properties that must be set for you to obtain a barcode are

Axbarcode1.CodeType specifies the barcode type required

Axbarcode1.Caption specifies the characters that make up the code

A typical example of setting these properties is:

Axbarcode1.CodeType=8 rem code type is 8 for Code-39 type barcode

Axbarcode1.Caption="123456" rem code is 123456

More:

Methods of using the barcode image


Methods of using the barcode image

To paint the control's Picture on the form use the PaintPicture method, or draw your own bars using the Printers Line method. Using the PaintPicture method the code will look like this:

If Axbarcode1.ErrorCode = 0 Then
Form1.PaintPicture Axbarcode1.Picture, 20, 20, i, j

where the (20,20) specifies the coordinates on the form of the top left-hand corner of the barcode image, and i and j represent the required width and height of the image respectively.

The control's Picture may be passed to the clipboard using

I = Axbarcode1.CopyImage()

The Visual Basic Picture object contains a metafile image of the generated barcode. In the event of an error in barcode image generation the image is empty, and the ErrorCode property is set to a non-zero value.

The control's Picture may be printed using the PaintPicture method of the Printer object, eg.

Printer.ScaleMode = 6 ' sets printer scale to mm

Printer.PaintPicture Axbarcode1.Picture, 20, 20, Axbarcode1. PictureWidth, Axbarcode1. PictureHeight

Printer.NewPage

Printer.EndDoc

Where the (20,20) refers to the top, left coordinates of the barcode image on the printer's page.

Note that the PrintForm method may also be used, although on some systems this may show images of unsuitable resolution.

For printing under VB.NET or from C# see the example in Creating a barcode Picture under Using Active Barcode Component in VB or .NET.

The image created by the Active Barcode Component may also be saved in a file in a graphics format using the SaveImage(filename) method. The image type must be specified by using the permitted filename extensions - .wmf, .bmp, .eps, .pcx, png .or .gif.

More:

Required properties


Required properties

The following properties are required - although all are provided with default values.

More:

AllowRightProps

AutoParity

BackColor

BarRatio

BarReduce

BearerBarThickness

BorderSize

Caption

CharSpacing

CodeType

ExtendBearers

Extra1

Extra2

Font

ForeColor

GapToText

ImageHeight

ImageWidth

JustifyText

Left

MarginSize

NominalSize

Orientation

SaveImageFile

ScaleMode

ShowBearerBars

ShowCheckDigit

ShowLightMargins

ShowText

TargetHdpi

TargetVdpi

Top

TransparentBackground

Units

UseEnhanced

Width

xunit


AllowRightProps

Type BOOL

Default: FALSE

Allowed values: TRUE (allows the property pages to be displayed on a right mouse button click within the controls visible area)

FALSE (property pages not displayed)

More:

AutoParity


AutoParity

Type: BOOL

Default: FALSE

Allowed values: FALSE (checkdigit characters not calculated)

TRUE (checkdigit characters calculated and appended to code for appropriate code types)

More:

BackColor


BackColor

Type: LONG

Default: &H00FFFFFF&

Allowed values: 0 (black)

to &H00FFFFFF& (white)

Sets the colour of the image background. This value may be over-ridden by the Transparent property.

More:

BarRatio


BarRatio

Type: SHORT

Default 25

Allowed values: 20 - 30

This setting allows some barcode types to have the Wide bar/Narrow bar ratio modified. The value is 10 times the ratio, so the default ratio is 2.5

Applies mainly to Code 39 and Interleaved 2 of 5 barcodes.

More:

BarReduce


BarReduce

Type: SHORT

Default: 0 the thickness of each line drawn on the barcode image is reduced by this percentage amount. This property may be used to compensate for ink spreading during wet-ink printing. If a negative value is used the widths of the bars are reduced by the percentage of the thinnest bar.

Allowed values: 0 - 50 (%) 100-150 (%)

Values greater than 100 may be used to increase bar widths. If a negative value is used the widths of the bars are increased by the percentage of the thinnest bar.

More:

BearerBarThickness


BearerBarThickness

Type: SHORT

Default: 0

Allowed values: 0 - 10000

Allows the thickness of bearer bars for those barcode which support bearers to be set in units of the current ScaleMode.

Note that for most barcode types the number of bearer bars displayed depends on the setting of the ShowBearerBars property. If ShowBearerBars is True the bars are displayed above and below the barcode. If ShowBearerBars is False then only a single bearer bar is displayed above the barcode.

More:

BorderSize


BorderSize

Type: SHORT

Default: 0

Allowed values: 0 (no border)

to 255 in points

More:

Caption


Caption

Type: BSTR

Default: "12345"

Allowed values: Any text string.

Note: only text strings recognised as valid barcodes will result in a barcode picture. Illegal text string will cause an ErrorCode value to be set.

The Caption should be the last property set - as setting this property causes the barcode image to be recreated.

More:

CharSpacing


CharSpacing

Type: SHORT

Default: 0

Allowed values 0 and 10 - 100

The percentage of the barcode width, which the text under the barcode will take up. A value of 0 causes the characters to be displayed with their "normal" spacing. It is the users responsibility to ensure that the value provided is sensible in comparison with the fontsize.

More:

CodeType


CodeType

Type: SHORT

For Active Barcode Control Universal

Default: 8

Allowed values: The range of values defined in the barcode types table in the Barcodes HELP file.

For all other controls

Default: 0

Allowed values:

Active Barcode Control Code Standard
0 – Code 39
1 – Extended Code 39
2 – Code 93
3 – Extended Code 93
4 – Code 128
5 – Code 128 subtype A
6 – Code 128 subtype B
7 – Interleaved 2 of 5
8 – Matrix 2 of 5
Note: Code 128 subtype C is an automatic selection.

Active Barcode Control GS1
0 – EAN-13 / JAN-13 etc.
1 – EAN-8
2 – EAN-13 + 2 digits
3 – EAN-13 + 5 digits
4 – UPC-A
5 – UPC-E
6 – UPC-A + 2 digits
7 – UPC-A + 5 digits
8 – EAN-8 + 2 digits
9 – EAN-8 + 5 digits
10 – UPC-E + 2 digits
11 – UPC-E + 5 digits
12 – EAN-14
13 – UPC-E0
14 – UPC-E1
15 – ITF-14
16 – GS1-128 (formerly EAN/UCC 128)
17 – SSCC (Serial Shipping Container Code)
18 – Databar Omnidirectional
19 – Databar Truncated
20 – Databar Limited
21 – Databar Expanded

More:

ExtendBearers


ExtendBearers

Type: BOOL

Default: FALSE

When TRUE allows bearer bars to extend into light margins. When FALSE bearer bars cover the bars only.

More:

Extra1


Extra1

Type: BOOL

Default FALSE

These additional properties are not normally used. However, they do provide additional functions for a limited number of specific barcode types. See Barcodes HELP for details.

More:

Extra2


Extra2

Type: BOOL

Default FALSE

These additional properties are not normally used. However, they do provide additional functions for a limited number of specific barcode types. See Barcodes HELP for details.

More:

Font


Font

Type: FONT

Default: Arial 10 point

Allowed values: Any accessible TrueType font.

Font details may be specified using the font parameters, eg.

Axbarcode1.FontName="Arial"
Axbarcode1.FontSize=8

More:

ForeColor


ForeColor

Type: LONG

Default: 0

Allowed values: 0 (black)

to &H00FFFFFF& (white)

Set the colour of the image foreground, i.e. the bars and text colour.

More:

GapToText


GapToText

Type: SHORT

Default: 0 A value given as a percentage of the text font point size by which text is raised within its bounding rectangle.

Allowed values: 0-100 (%)

Note: For most applications this value should be set to 0.

More:

ImageHeight


ImageHeight

Type: FLOAT

Default: 20 mm

Allowed values: 5 mm (minimum)

to form height in units determined by the setting of ScaleMode

The target height of the barcode image. Note that this is the target size of the resizable metafile image. The font height will be as requested if the metafile is reproduced at this size. If the metafile is resized to say double this value then the font will also be increase in absolute size. Also this value will be placed in the metafile header for those applications that can reproduce metafiles at their specified size.

More:

ImageWidth


ImageWidth

Type: FLOAT

Default: 25 mm

Allowed values: 0.1 - 30,000

to form width in units determined by the setting of ScaleMode

The target width of the barcode image. Note that this is the target size of the resizable metafile. The font height will be as requested if the metafile is reproduced at this size. If the metafile is resized to say double this value then the font will also be increase in absolute size. Also this value will be placed in the metafile header for those applications that can reproduce metafiles at their specified size. If the Xunit property is non-zero then the ImageWidth property is over-ridden by a value calculated from the value of Xunit and the number of elements in the barcode.

More:

JustifyText


JustifyText

Type: SHORT

Default: 0

Allowed values 0,1 and 2

JustifyText sets the justification of any text displayed under the barcode. A value of 0 centres the text, 1 gives left justification and 2 gives right justification. Justification is to the outside of the light margins, so no justification can be used when light margin indicators are displayed.

More:

Left


Left

Type: SHORT

Default: value determined when user adds control to a form.

Note this is the Left position of the Control's rectangle.

More:

MarginSize


MarginSize

Type: FLOAT

Default: 0

Allowed values: 0 - 20000

The MarginSize property sets the Light Margin space on either side of a barcode image. The units are the units specified by the current ScaleMode.

More:

NominalSize


NominalSize

Type: SHORT

Default: 0 When this property is set to a value between 50 and 200 the width of the image created will be scaled to generate that percentage of the barcodes Standard. When this property is 0 no scaling is applied.

Allowed values: 0 or 50-200

Note that this feature is relevant only for some EAN, UPC and ITF code types. It is ignored for barcode types that do not have a standard size.

More:

Orientation


Orientation

Type: SHORT

Default: 0 The value of this parameter determines the orientation of the barcode image created.

Allowed values: 0 = normal orientation

1 = image rotated left by 90 degrees (clockwise)

2 = image rotated right by 90 degrees (anti-clockwise)

3 = image inverted.

Note that the rotation of text is only supported by TrueType and other rotatable fonts. Note also that some applications do not correctly handle metafiles that contain rotated text.

More:

SaveImageFile


SaveImageFile

Type: LPCTSTR

No default value.

When set the current barcode image is saved to the specified filename, exactly as when using the SaveImage method.

Eg. Axbarcode1.SaveFileImage="c:\barimage.wmf"

A fully qualified filename is required, and the extension is taken to determine the type of graphic file saved. See the SaveImage method for details.

More:

ScaleMode


ScaleMode

Type SHORT

Default: 6

The scaling mode applied to values of ImageWidth and ImageHeight values.

Allowed values:

0 - Windows HIMETRIC (0.01 mm)
1 - Twips
2 - Points
3 - Windows TEXT
4 - Windows HIENGLISH (0.001 inches)
5 - Inches
6 - millimetres
7 – centimetres

More:

ShowBearerBars


ShowBearerBars

Type: BOOL

Default: FALSE

Allowed values: TRUE or FALSE

When TRUE causes bearer bars to be draw above and below the barcode. When FALSE no bearer bars are drawn if the BearerBarThickness property is zero. Otherwise a FALSE setting causing only a single bearer bar to be displayed above the barcode.

More:

ShowCheckDigit


ShowCheckDigit

Type: BOOL

Default: 0 When set to 1 this property causes the any automatically calculated check digit to be included in the any text displayed along with the barcode. When set to 0 the check digit is not displayed.

Note that this property has no effect on those codetypes for which the checkdigit display is mandatory (including EAN and UPC codes).

More:

ShowLightMargins


ShowLightMargins

Type: BOOL

Default: FALSE A value of TRUE causes the light margin indicators to be displayed. For some EAN barcodes there are recommended ways for the margin indicators to be shown on the image, and the Prefix code and checkdigit for UPC-A and UPC-E codetype to be displayed in the light margins. A value of FALSE prevents the display of the light margin indicators.

Note that for ITF files specifying LightMargins=1 causes the border bars between the extremes of the bearer bars to be drawn. The required light margin distances are always included in ITF codes.

More:

ShowText


ShowText

Type: BOOL

Default: TRUE

Allowed values FALSE (text version of the code is NOT included in the barcode image)

TRUE (text version of the code IS included in the barcode image)

More:

TargetHdpi


TargetHdpi

Type: SHORT

Default: 600

Allowed values: 72 - 4800

Target device (eg. Printer) horizontal resolution (in dpi) for bitmap based images

More:

TargetVdpi


TargetVdpi

Type: SHORT

Default: 600

Allowed values: 72 - 4800

Target device (eg. Printer) horizontal resolution (in dpi) for bitmap based images

More:

Top


Top

Type: SHORT

Default: value determined when user adds control to a form.

Note this is the Top position available for the Control's icon. It is not related to the barcode picture. In most case the Control will be set to invisible, so this parameter may be ignored.

More:

TransparentBackground


TransparentBackground

Type: BOOL

Default: FALSE

Allowed values TRUE or FALSE. When set to TRUE this property causes the barcode image to be created on a transparent background (ie. and background colour is ignored). The property should be set to 1 only by users who are confident that the final barcode image will be produced on a background that does not interfere with barcode scanning.

More:

Units


Units

Type: BSTR

Returns the current units in words, as set using the ScaleMode parameter.

More:

UseEnhanced


UseEnhanced

Type: BOOL

Default: TRUE

Allowed values: TRUE and FLASE

When TRUE, an Enhanced metafile image is used to draw the barcode image on the visible control. When FALSE a standard Windows Metafile is used.

More:

Width


Width

Type: SHORT

Default: value determined when user adds control to a form.

Note this is the Width available for the Control's icon. It is not related to the barcode picture. In most case the Control will be set to invisible, so this parameter may be ignored.

More:

xunit


xunit

Type: SHORT

Default: 0

Allowed range: 10 - 255

The xunit property may be used to specify the width (in Mils) of the smallest element in the barcode.

Note that setting this property to a value other than 0 causes the control to resize itself to a width calculated from the number of X units in the barcodes. Using values smaller than 8 will produce a barcode image, but that image will not meet standard specifications and may not scan.

More:

Information properties


Information properties

More:

CodeName

CodeNameB

ErrorCode

HasParity

Nrequired

Pattern

Picture

PictureHeight

PictureWidth

String2


CodeName

Returns: the barcode name of the current barcode type as an LPSTR string.

More:

CodeNameB


CodeNameB

Returns: the barcode name of the current barcode type as a BSTR string.

More:

ErrorCode


ErrorCode

Type: SHORT

Returns a value representing the error code if a valid barcode image cannot be created. Otherwise returns 0.

Read only. Do not set this property.

More:

HasParity


HasParity

Type BOOL

Default: returns TRUE for code types that allow the inclusion of a checksum, otherwise returns FALSE.

Note that this property returns FALSE for GS1-128 and Code 128 in spite of the fact that these codes define checksum digits. This is because these codes cannot be used without the check digits and these digits are always calculated by the control and are not under user control. Check digits for these codes are not displayed.

Read only. Do not set this property. The value of this parameter can be determined following the setting of code type.

More:

Nrequired


Nrequired

Type: SHORT

Returns: 0 or the number of characters required for a valid barcode of the current type. 0 indicates any number of characters permitted.

Read only. Do not set this property. The value of this parameter can be determined following the setting of the code type

The value returned depends on the current setting for AutoParity - ie. the value specifies the number of characters that need to be provided by the user.

More:

Pattern


Pattern

Type: BSTR

Returns: A Visual Basic string containing a pattern of 0s and 1s, where 0 represents a space of minimum width and a 1 represents a bar of minimum width. Within Visual Basic the 1s may be used to indicate that a bar (filled rectangle) must be drawn.

Read only. Do not set this property.

More:

Picture


Picture

Type: PICTURE

Returns: The Picture of metafile type returned by the Active Barcode Component. This contains the image of the barcode and (if enabled) its text.

Read only. Do not set this property.

More:

PictureHeight


PictureHeight

Type: FLOAT

Returns: the height of the picture generated (in units determined by the setting of ScaleMode)

Read only. Do not set this property.

Note that PictureHeight differs from ImageHeight if the barcode image is rotated left or right.

More:

PictureWidth


PictureWidth

Type: FLOAT

Returns: the width of the picture generated (in units determined by the setting of ScaleMode)

Read only. Do not set this property.

Note that PictureWidth differs from ImageWidth if the barcode image is rotated left or right, or if the PictureWidth is calculated from an Xunit value.

More:

String2


String2

Type: BSTR

Returns the Caption property plus any additional characters generated as check digits.

Read only. Do not set this property.

More:

Methods


Methods

More:

CopyBitmap()

CopyImage()

GetError()

GetTypeName()

GetTypeNameB()

Refresh()

SaveImage(filename)

ShowProps()


CopyBitmap()

This method causes a barcode image to be created and copied to the Windows clipboard. CopyImage copies the barcode image as a Windows metafile, and CopyBitmap copies the image as a bitmap. Both functions return 0 if an error occurs and one if the copy is successful.

More:

CopyImage()


CopyImage()

This method causes a barcode image to be created and copied to the Windows clipboard. CopyImage copies the barcode image as a Windows metafile, and CopyBitmap copies the image as a bitmap. Both functions return 0 if an error occurs and one if the copy is successful.

More:

GetError()


GetError()

Type: BSTR

Syntax: GetError(LPINT Errorcode)

The GetError(Errorcode) method returns the text (a BSTR string) of the error message corresponding to the Errorcode value. So a string variable may be filled with the error message using

X$=Axbarcode1.GetError(Axbarcode1.ErrorCode)

More:

GetTypeName()


GetTypeName()

Type: SHORT

Syntax: GetTypeName(int, BSTR)

Returns: the barcode name of the current barcode type as a BSTR string in the calling parameter.

May be determined after setting the code type (eg. For filling a list box). Return a NULL string (zero length) for invalid code type.

More:

GetTypeNameB()


GetTypeNameB()

Type: BSTR

Syntax: GetTypeNameB(int)

Returns: the barcode name of the current barcode type as a BSTR string.

May be determined after setting the code type (eg. For filling a list box). Return a NULL string (zero length) for invalid code type.

More:

Refresh()


Refresh()

This method causes the barcode calculation to be repeated and the Image (if being shown) to be redrawn.

More:

SaveImage(filename)


SaveImage(filename)

When called with a valid filename (including extension), this method copies the barcode image in a graphics format to a named disk file. The filename parameter must contain the fully qualified filename of the file that will receive the image. The specified directory path must exist. If the file exists it will be overwritten; if it does not exist it will be created. A return value of 0 indicates an error.

The extension of the filename specifies the type of file to be created.

The following filename extensions are supported by SaveImage():

.WMF = Windows metafile image.

.BMP = monochrome (1 bpp) Bitmap image.

.BM8 = 8 bpp colour Bitmap image – NOTE: file will be saved with .BMP extension.

.DIB = Device Independent Bitmap image.

.EPS = encapsulated PostScript file,

.PCX = Paintbrush format bitmap,

.PNG = Portable Network Graphic image

.GIF = Compuserve graphic.]

Note that the Property SaveImageFile may also be set to a filename to initiate the saving of a graphic file.

More:

ShowProps()


ShowProps()

Displays the property pages for the control.

More:

Events


Events

The following events are exported by the control and may be used by the container:

DblClick() – mouse double click

KeyDown (short KeyCode, short Shift) – a key pressed down; KeyCode identifies the keycode and Shift represents the state of the shift key

KeyUp (short KeyCode, short Shift) – a key released

MouseDown (short Button, short Shift, OLE_XPOS_PIXELS x, OLE_XPOS_PIXELS y) – a mouse button is pressed, Button identifies the mouse button, Shift represents the state of the shift key, a and y identify the location of mouse cursor.

MouseUp (short Button, short Shift, OLE_XPOS_PIXELS x, OLE_XPOS_PIXELS y) – a mouse button is released.

More:

Error codes


Error codes

The Property Axbarcode1.ErrorCode AFTER Axbarcode1.Caption has been set may contain an error code if the component was unable to generate a barcode Picture. The property value will be one of the following:

0 No error
1 Wrong code length
2 Unrecognised code type
3 Wrong add-on code length
4 Illegal character in code
5 Error in embedded code
6 Generated line width less than 1 unit
7 Invalid text font
8 Invalid device context
9 Invalid Caption property
10 Error writing disk file

More:

2D Components


2D Components

Active 2D-Barcode Components are Active-X/Automation Controls that allow 2D-barcode images to be created within the user’s own software. A barcode image may be displayed on screen, printed on a printer, save to a disk file, or passed to the Windows clipboard for incorporation into another Windows application.

Although primarily designed for Microsoft's Visual Basic 6 and VBA, Active-Barcode Component may be employed with other Active-X-enabled applications, such as Delphi or the Visual Basic for Applications provided in Microsoft Office 2003 or later and later.

Users should note that the encoding calculations are performed when the component’s image is created, by being used, accessed or copied. Information properties (such as PictureWidth) are not available until the image has been created.

More:

2D-Barcode Property pages

Setting the image size

Binary data


2D-Barcode Property pages

Active 2D-Barcode Component may be inserted into Container programs (such as WordPad) generally by selecting Insert Object from the EDIT or INSERT menus and choosing A2barcode Control from the list of options presented.

The properties of the barcode image may be set by selecting the barcode and either double-clicking on it, or by summoning its Property Pages dialog from the Edit – A2barcode Control Object menu item.

The Property Pages dialog provides a tabbed dialog box containing four pages.

The Data page contains a text version of the data being supplied to the component to create the barcode.

If the data contains non-printable (or non-Windows) characters, then the display may be rather strange. Such data will normally be passed in via programming rather than by using the Data window.

The General Page provides the user with the opportunity to set the Codetype, the Code value (the Caption), and the target height and width. Checkboxes are provided to allow the Nominal size to be specified (valid only for barcodes which have a nominal size), and for the check digit to be calculated automatically (for those codes which have check digits. An X unit box allows the width of the barcode to be calculated by the control, using the X unit size The X unit is the width of the thinnest bar (in mils – 0.001 inches, not mm). If X is provided as 0 then the width of the barcode is determined by the content of the width box.

Some of the Active Barcode Components will include additional features on this property page.

Details of the properties are given in the Reference section.

The Appearance page enables most of the remaining properties to be specified, either through checkboxes, by entering a border size in the edit box, or selecting a colour by pushing the foreground or background colour change button.

Each Property page contains an OK button which, if pushed causes the current contents of all the pages to be used in re-creating the barcode image. The pages also contain a Cancel button that may be used to close the Property pages dialog and discard any changes made.

More:

Setting the image size


Setting the image size

Active 2D-Barcode Component creates a barcode image at a size specified by the user. However, the metafile image is fully resizable by the user – so can be displayed or printed at a size other than that originally created.

There are two ways of specifying the size at which the image is created:

1. Any of the supported barcode type may have the image size specified by setting the Xunit property to the width of the narrowest element in the barcode (and, where relevant the HeightToWidth property). Xunit values are specified in Mils. In this case the initial setting of the ImageWidth property is ignored. After the image has been created the PictureWidth and PictureHeight properties contain the actual width and height of the barcode image.

2. Any barcode type may have the image size specified by setting the ImageWidth and ImageHeight properties when the Xunit property is set to 0.

More:

Binary data


Binary data

Active 2D-Barcode Component can handle binary data, but special considerations arise when that data will contain ASCII 0 (null) characters. The Caption property is treated as a C string – and so terminates at the first null character.

To send binary data containing ASCII 0 characters to the control one of two available Methods should be used:

SetByteStream(LPCTSTR lpstream, short nlength)

or

SetIntStream(short FAR* lpstream, short nlength)

In both cases the byte data is pointed to by the lpstream parameter, and the length of the data is specified in the nlength parameter.

A Visual Basic routine for using binary data as a string of specified length is:

Private Sub Command1_Click()
Dim bts(1000) As Integer
x$ = String(372, vbNullChar)
n = Len(x$)

Open "data.dat" For Binary As #1 Len = 372
Get #1, , x$
Close #1

Call A2barcode1.SetByteStream(z$, n)
Image1.Picture = A2barcode1.Picture

End Sub

An alternative routine, in which the data is encoded in a integer array is:

Private Sub Command1_Click()
Dim bts(1000) As Integer
x$ = String(372, vbNullChar)
n = Len(x$)

Open "data.dat" For Binary As #1 Len = 372
Get #1, , x$
Close #1

For i = 1 To n
c$ = Mid$(x$, i, 1)
If (c$ = "") Then
j = 0
Else
j = Asc(c$)
End If
bts(i) = j
Next i

Call A2barcode1.SetIntStream(bts(1), n)
Image1.Picture = A2barcode1.Picture

End Sub

More:

2D Component Reference


2D Component Reference

More:

Summary of Properties and Methods

Required properties

Information properties

Methods

Events


Summary of Properties and Methods

Active 2D-Barcode Component properties fall into two categories – those that are required to specify characteristics of the barcode image, and those, which provide information about the barcode.

The most important properties and methods are outlined below, and followed by sections in which the properties and methods are defined in detail.

More:

Component properties.

Methods of using the barcode image


Component properties.

The properties which can be set to generate an image

A2barcode1.BackColor the colour behind the bars

A2barcode1.BorderSize specifies the thickness of any border around the image (in points)

A2barcode1.Caption specifies the characters that make up the code

A2barcode1.CodeType specifies the barcode type required

A2barcode1.ForeColor the colour of the bars and any text under the bars

A2barcode1.HeightToWidth specifies the height to width ratio of bar for PDF417

A2barcode1.ImageHeight required target height of barcode image (in units determined by the setting of ScaleMode)

A2barcode1.ImageWidth required target width of barcode image (in units determined by the setting of ScaleMode)

A2barcode1.LineReduce specifies the percentage reduction in bar thickness (useful for allowing for ink spread in wet-ink printing processes.

A2barcode1.ScaleMode specifies the units of ImageHeight, ImageWidth, PictureWidth and PictureHeight parameters (default is 6 = mm)

Axbarcode1.TargetHdpi Target device horizontal resolution (in dpi) for bitmap based images

Axbarcode1.TargetVdpi Target device vertical resolution (in dpi) for bitmap based images

Many of these properties have default values (see the reference section), so do not require changing if you can make do with the default values. The properties which must be set for you to obtain a barcode are

A2barcode1.CodeType specifies the barcode type required

A2barcode1.Caption specifies the characters, which make up the code

A typical example of setting these properties is:

A2barcode1.CodeType=2 rem code type is 2 for PDF417 type barcode

A2barcode1.Caption="123456" rem code is 123456

More:

Methods of using the barcode image


Methods of using the barcode image

To paint the control's Picture on the form use the PaintPicture method, or draw your own bars using the Printers Line method. Using the PaintPicture method the code will look like this:

If A2barcode1.ErrorCode = 0 Then
Form1.PaintPicture A2barcode1.Picture, 20, 20, i, j

where the (20,20) specifies the coordinates on the form of the top left-hand corner of the barcode image, and i and j represent the required width and height of the image respectively.

The control’s Picture may be passed to the clipboard using

I = A2barcode1.CopyImage()

The Visual Basic Picture object contains a metafile image of the generated barcode. In the event of an error in barcode image generation the image is empty, and the ErrorCode property is set to a non-zero value;

The control's Picture may be printed from VB6 using the PaintPicture method of the Printer object, eg.

Printer.ScaleMode = 6 ' sets printer scale to mm
Printer.PaintPicture A2barcode1.Picture, 20, 20, A2barcode1. PictureWidth, A2barcode1. PictureHeight
Printer.NewPage
Printer.EndDoc

Where the (20,20) refers to the top, left coordinates of the barcode image on the printer's page.

Note that the PrintForm method may also be used, although on some systems this may show images of unsuitable resolution.

For printing the image using VB.NET or C# see Creating a barcode picture under Using Active 2D Barcode Component in VB & .NET

The image created by the Active 2D-Barcode Component may also be saved in a file in a graphics format using the SaveImage(filename) method. The image type must be specified by using the permitted filename extensions - .wmf, .bmp, .eps, .pcx, png, or .gif.

More:

Required properties


Required properties

The following properties are required – although all are provided with default values.

More:

AllowRightProps

Columns

BackColor

BorderSize

Caption

CodeType

ForeColor

HeightToWidth

ImageHeight

ImageWidth

Left

LineReduce

Orientation

SaveImageFile

ScaleMode

TargetHdpi

TargetVdpi

Top

Transparent

UseEnhanced

Width

Xunit

AztecFlag

AztecMenu

SecurityLevel

Mode

FixSize

Scale

ReverseVideo


AllowRightProps

Type BOOL

Default: FALSE

Allowed values: TRUE (allows the property pages to be displayed on a right mouse button click within the controls visible area)

FALSE (property pages not displayed)

More:

Columns


Columns

Type: SHORT

Default: 1

This value specifies the number of column units used in generating the barcode for those barcode types that support specified symbol sizes (Aztec (Full Range mode), Datamatrix, PDF417, QR Code or Databar (Expanded stacked) barcodes). It is ignored for other barcode types.

For Aztec, Datamatrix and QR Code symbols the value determines the number of columns in the symbol. If the value is zero or less than the smallest symbol that can hold the data then the number of columns is determined by the data and the security level setting.

For Databar Expanded stacked symbols the value represents the width of the symbol in segment pairs.

For PDF417 symbols the value is the number of dataword columns that the control will attempt to fit the barcode image. It is important to note that not all values are possible (for example PDF barcode must have at least 3 rows).

More:

BackColor


BackColor

Type: LONG

Default: &H00FFFFFF&

Allowed values: 0 (black)

to &H00FFFFFF& (white)

Sets the colour of the image background. This value may be over-ridden by the Transparent property.

More:

BorderSize


Caption

Type: BSTR

Default: "12345"

Allowed values: Any text string.

Note: only text strings recognised as valid barcodes will result in a barcode picture. Illegal text string will cause an ErrorCode value to be set.

The Caption should be the last property set - as setting this property causes the barcode image to be recreated.

More:

CodeType


CodeType

Type: SHORT

Default: 0

Allowed values: For Active 2D-Barcode Universal the range of values defined in the
barcode types table below.

For Active Barcode Component PDF417 the allowed values are:

0 – PDF417 barcodes

1 – Micro PDF417 barcodes

For Active Barcode Component QR Code the allowed values are:

0 – QR Code barcodes

1 – Micro QR Code barcodes

For all other single barcode components the CodeType must be 0

For Active Barcode Component 2D Universal the CodeType values are:

Barcode | CodeType
Aztec | 0
DataMatrix | 1
PDF417 | 2
MaxiCode | 3
MicroPDF417 | 4
Databar (formerly RSS) | 5
QR Code | 6
Micro QR Code | 7

If you plan to use a specific barcode type you should examine the notes in the Barcodes Help on that type before printing any barcode images.

More:

ForeColor


ForeColor

Type: LONG

Default: 0

Allowed values: 0 (black)

to &H00FFFFFF& (white)

Set the colour of the image foreground, i.e. the bar colour.

More:

HeightToWidth


HeightToWidth

Type: SHORT

Default 3

Allowed values: 1 – 100

This setting allows the Height to Width ratio of the element used in PDF417 and Databar barcode construction to be selected by the user. For PDF417 and MicroPDF barcode the value should be 2 – 5, while for Databar barcodes the value should be 10 - 20.

Note that if the resizable barcode image is resized, then the actual height to width ratio which appear in the image will be different from that specified by this parameter.

More:

ImageHeight


ImageHeight

Type: SHORT

Default: 30 mm

Allowed values: 5 (minimum)

to form height in units determined by the setting of ScaleMode

The target height of the barcode image. Note that this is the target size of the resizable metafile image in units set by the ScaleMode property.

More:

ImageWidth


ImageWidth

Type: SHORT

Default: 30 mm

Allowed values: 0.1 – 30,000

to form width in units determined by the setting of ScaleMode

The target width of the barcode image. Note that this is the target size of the resizable metafile in units set by the ScaleMode property.

More:

Left


Left

Type: SORT

Default: value determined when user adds a control to a form.

Note this is the Left position available for the Control's rectangle.

More:

LineReduce


LineReduce

Type: SHORT

Default: 0 the thickness of each line drawn on the barcode image is reduced by this percentage amount. This property may be used to compensate for ink spreading during wet-ink printing. If a negative value is used the widths of the bars are reduced by the percentage of the thinnest bar.

Allowed values: 0 - 50 (%) 100-150 (%)

Values greater than 100 may be used to increase bar widths. If a negative value is used the widths of the bars are increased by the percentage of the thinnest bar.

For MaxiCode targeted for laser printing we recommend a value of 12.

For Aztec, Datamatrix and QR Code symbols positive or negative values both apply a change equal to the percentage of the size of a single element (ie. an X unit).

More:

Orientation


Orientation

Type: SHORT

Default: 0 The value of this parameter determines the orientation of the barcode image created.

Allowed values: 0 = normal orientation
1 = image rotated left by 90 degrees (clockwise)
2 = image rotated right by 90 degrees (anti-clockwise)
3 = image inverted.
4 = mirror image

Note that the rotation of text is only supported by TrueType and other rotatable fonts. Note also that some applications do not correctly handle metafiles that contain rotated text.

Mirrored images of 2D barcodes will not in general be scannable. This facility should be used only where the barcode is to be remirrored during the printing process.

More:

SaveImageFile


SaveImageFile

Type: LPCTSTR

No default value.

When set the current barcode image is saved to the specified filename, exactly as when using the SaveImage method.

Eg. A2barcode1.SaveFileImage="c:\barimage.wmf"

A fully qualified filename is required, and the extension is taken to determine the type of graphic file saved. See the SaveImage method for details.

More:

ScaleMode


ScaleMode

Type SHORT

Default: 6

The scaling mode applied to values of ImageWidth and ImageHeight values.

Allowed values:

0 - Windows HIMETRIC (0.01 mm)
1 - Twips
2 - Points
3 – Windows TEXT
4 – Windows HIENGLISH (0.001 inches)
5 - Inches
6 – millimetres
7 – centimetres

More:

TargetHdpi


Top

Type: SHORT

Default: value determined when user adds control to a form.

Note this is the Top position available for the Control's icon. It is not related to the barcode picture. In most case the Control will be set to invisible, so this parameter may be ignored.

More:

Transparent


Transparent

Type: BOOL

Default: FALSE

Allowed values TRUE or FALSE. When set to TRUE this property causes the barcode image to be created on a transparent background (ie. and background colour is ignored). The property should be set to TRUE only by users who are confident that the final barcode image will be produced on a background that does not interfere with barcode scanning.

More:

UseEnhanced


Width

Type: SHORT

Default: value determined when user adds control to a form.

Note this is the Width available for the Control's icon. It is not related to the barcode picture. In most case the Control will be set to invisible, so this parameter may be ignored.

More:

Xunit


Xunit

Type: SHORT

Default: 0

Allowed range: 10 – 255

Setting this property to a value other than 0 causes the control to resize itself to a size calculated from the number of X units in the barcodes (and, in the case of PDF417, from the height/width ratio). Using values smaller than 8 will produce a barcode image, but that image will not meet standard specifications and may not scan.

Note that the units of this quantity are the industry standard mils. The units of this quantity are NOT affected by the ScaleMode.

More:

AztecFlag


AztecFlag

Type: SHORT

Default: 0

Allowed range: 0

Despite its name the AztecFlag is not used just for Aztec Symbols in this version. In order to allow additional facilities to be added without introducing incompatabilities with earlier version, this property is used for the following purpose:

For Aztec, Datamatrix, PDF417 and QR Code symbols setting bit 7 (ie decimal 128) of this flag forces the encoding of Unicode within the symbol. This is useful for encoding non-western character sets within the symbols. It is NOT necessary to set this flag for encoding Kanji mode QR symbols.

For PDF417 symbols setting bit1 of the AztecFlag (ie to 2) generates Truncated PDF417 symbols. Truncated symbols are recommended only for in-house applications because the truncation, while producing a smaller barcode, does remove the error checking characters and stop characters at the end of each row.

For Datamatrix symbols setting bit 9 (decimal 512) forces the encoding to be in Base256 mode as required by some applications by Deutschepost. Setting bit 6 (ie decimal 64) forces the creation of a Deutsche Post PostMatrix symbol (with two additional vertical bars).

More:

AztecMenu


AztecMenu

Type: SHORT

Default: 0

Allowed range: 0,2

Despite its name the AztecMenu is not used for Aztec Symbols in this version. However, in order to allow additional facilities to be added without introducing incompatibilities with earlier version, this property is used for the following purpose:

In the 2D Universal, QR Code and Datamatrix components this property is used to control the encoding. If the property is 2 then the Caption property is scanned for the presence of GS1 Application Identifiers, brackets are removed and the result is encoded using GS1 Datamatrix or GS1 QR Code encoding rules. If the property is 0 then industry standard encoding is used.

Note that if the first data character in a Datamatrix datastream is FNC1 (ASCII 232) then this has the same effect as setting the AztecMenu property to 2.

More:

SecurityLevel


SecurityLevel

Type: SHORT

Default: 0

Allowed range: Varies with barcode type

For Aztec, Datamatrix, QR and PDF allowed values see the Barcode Types section. For Maxicode barcodes this property is ignored. For DATABAR Expanded barcodes the value is used as the Linkage.

More:

Mode


Mode

Type: SHORT

Default: 0

Allowed range: Varies with barcode type

Note that setting this property to a value other than 0 causes the control to create a barcode that starts in a mode other than automatic.

The allowed values are shown in the tables below.

For Aztec

Mode value | Aztec mode
0 | Normal
1 | Compact
2 | Full range
3 | Rune

For DataMatrix

Mode value | DataMatrix type
0 | Auto Square
1 | Auto Rectangular
2 | ASCII Square
3 | ASCII Rectangular
4 | C40 Square
5 | C40 Rectangular
6 | Text Square
7 | Text Rectangular
8 | X12 Square
9 | X12 Rectangular
10 | EDIFACT Square
11 | EDIFACT Rectangular
12 | Base 256 Square
13 | Base 256 Rectangular

For Databar

Mode value | Databar type
0 | Omnidirectional
1 | Truncated
2 | Limited
3 | Stacked
4 | Stacked Omnidirectional
5 | Expanded
6 | Expanded Stacked

For PDF417

Mode value | PDF417 Mode
0 | Exc - Alpha
1 | Exc – Lower case
2 | Exc – Mixed
3 | Exc - Punctuation
4 | Binary/ASCII plus
5 | Numeric

For MaxiCode

Mode Value | MaxiCode Mode
0 | obsolete, not supported
1 | obsolete, not supported
2 | Mode 2 (Structured Carrier Message – Numeric Postal Code)
3 | Mode 3 (Structured Carrier Message – Alphanumeric Postal Code)
4 | Mode 4 – Standard Symbol (SEC)
5 | Mode 5 – Full EEC Symbol
6 | Mode 6 – Reader Program (SEC)

For QR Code

Mode value | QR mode
0 | Automatic
1 | Alphanumeric
2 | Byte
3 | Kanji*

*Kanji characters are not detected in automatic mode. To encode Kanji the Kanji mode must be selected.

More:

FixSize


FixSize

Type: BOOL

Default: FALSE

Allowed range: TRUE/FALSE

When TRUE allows the size of the control to change to reflect the size calculated from a specified Xunit value. When FALSE the control size remains fixed, and the barcode image expands or contracts to fill the control.

More:

Scale


Scale

Type: REAL (float)

Default: 100.0

Read only

Return the scaling factor between internal units (HIMETRIC) and the coordinates used for ImageHeight and ImageWidth as specified by the ScaleMode setting.

More:

ReverseVideo


ReverseVideo

Type: BOOL

Default: FALSE

Allowed range: TRUE/FALSE

Note that setting this property to TRUE causes the image to be displayed in Reverse Video (i.e. White bars on a black background).

More:

Information properties


Information properties

More:

CodeName

CodeNameB

ErrorCode

PatternString

Picture

PictureHeight

PictureWidth

Units


ErrorCode

Type: SHORT

Returns a value representing the error code if a valid barcode image cannot be created. Otherwise returns 0.

Read only. Do not set this property.

More:

PatternString


PatternString

Type: BSTR

Note: NOT applicable to Maxicode or DATABAR barcodes.

A pattern of characters representing the bars and spaces in the barcode image, with each row in barcode image being terminated by a linefeed [CHR(10)] character.

For the matrix barcode types Aztec and DataMatrix a ‘1’ (CHR(49) represent a bar and a ‘0’ (CHR(48)) represents a space. These patterns include the finder patterns.

For the stacked barcode types PDF417 and MicroPDF417 the pattern string characters represent the alternating bars and spaces, with the value of each character representing the length (ie. Number of elements) of that type. Thus initial characters ‘821’ would represent a bar of width 8 units, followed by a space of width 2 units, followed by a bar of width 1 unit.

Read only. Do not set this property.

More:

Picture


PictureHeight

Type: FLOAT

Returns: the height of the picture generated (in units determined by the setting of ScaleMode)

Read only. Do not set this property.

Note that PictureHeight differs from ImageHeight if the barcode image is rotated left or right. This value will be placed in the metafile header for those applications which can reproduce metafiles at their specified size.

More:

PictureWidth


PictureWidth

Type: FLOAT

Returns: the width of the picture generated (in units determined by the setting of ScaleMode)

Read only. Do not set this property.

Note that PictureWidth differs from ImageWidth if the barcode image is rotated left or right. This value will be placed in the metafile header for those applications which can reproduce metafiles at their specified size.

More:

Units


Units

Type: BSTR

READ ONLY

Returns the current units in words, as set using the ScaleMode parameter.

More:

Methods


Methods

More:

CopyBitmap()

CopyImage()

GetError()

GetModeName()

GetMaxLevel()

GetTypeName()

GetTypeNameB()

Refresh()

SaveImage(filename)

SetByteStream()

SetIntStream()

ShowProps()


GetError()

Type: BSTR

Syntax: GetError(LPINT errorcode)

The GetError(Errorcode) method returns the text (a BSTR string) of the error message corresponding to the Errorcode value. So a string variable may be filled with the error message using

X$=Uniocx1.GetError(Uniocx.Errorcode)

More:

GetModeName()


GetModeName()

Type: BSTR

Syntax: GetModeName(LPINT mode)

Return the name of 2D mode for the barcode type. For example, DataMatrix barcodes have the mode name “Square” for mode=0 and “Rectangular” for mode=1.

An invalid value in mode will return an empty string, so this method may be used for enumerating the available modes; for example:

For i = 0 To 10
x$ = Aztocx1.GetModeName(i)
If (Len(x$) > 0) Then
Combomode.AddItem (x$)
Else
Exit For
End If
Next

More:

GetMaxLevel()


GetMaxLevel()

Type: LONG

Syntax: GetMaxLevel(LPINT mode)

Returns the number of security levels valid for the mode. For example, Aztec in Normal mode can have 99 levels, but in Compact mode has only 4.

More:

GetTypeName()


GetTypeNameB()

Type: BSTR

Syntax: GetTypeName(int)

Returns: the barcode name of the current barcode type as a BSTR string.

May be determined after setting the code type (eg. For filling a list box). Return a NULL string (zero length) for invalid code type.

More:

Refresh()


Refresh()

This method causes the barcode calculation to be repeated and the Image (if being shown) to be withdrawn.

More:

SaveImage(filename)


SaveImage(filename)

When called with a valid filename (including extension), this method copies the barcode image to a named disk file. The filename parameter must contain the fully qualified filename of the file which will receive the image. The specified directory path must exist. If the file exists it will be overwritten; if it does not exist it will be created. A return value of 0 indicates an error.

The extension of the filename specifies the type of file to be created.

The following filename extensions are supported by SaveImage():

.WMF = Windows metafile image.

.BMP = monochrome (1 bpp) Bitmap image.

.BM8 = 8 bpp colour Bitmap image – NOTE: file will be saved with .BMP extension.

.DIB = Device Independent Bitmap image.

.EPS = encapsulated PostScript file,

.PCX = Paintbrush format bitmap,

.PNG = Portable Network Graphic image

.GIF = Compuserve graphic.]

Note that the Property SaveImageFile may also be set to a filename to initiate the saving of a graphic file.

More:

SetByteStream()


SetByteStream()

This method makes the source of the barcode data the bytes stream lpstream of length nlength. The Caption property is ignored once this method is called and any existing Caption string is set to Null.

This method is useful if binary data containing ASCII 0 characters is to be encoded into the barcode.

Declaration

void SetByteStream(LPCTSTR lpstream, short nlength)

More:

SetIntStream()


SetIntStream()

This method makes the source of the barcode data the short integer array stream lpstream of length nlength. The Caption property is ignored once this method is called and any existing Caption string is set to Null.

Note that each data byte is taken from the LO byte of each integer in the array.

This method is useful if binary data containing ASCII 0 characters is to be encoded into the barcode.

Declaration

void SetIntStream(short FAR* lpstream, short nlength)

More:

ShowProps()


Events

The following events are exported by the control and may be used by the container:

DblClick() – mouse double click

KeyDown(short KeyCode, short Shift) – a key pressed down; KeyCode identifies the keycode and Shift represents the state of the shift key

KeyUp(short KeyCode, short Shift) – a key released

MouseDown(short Button, short Shift, OLE_XPOS_PIXELS x, OLE_XPOS_PIXELS y) – a mouse button is pressed, Button identifies the mouse button, Shift represents the state of the shift key, a and y identify the location of mouse cursor.

MouseUp(short Button, short Shift, OLE_XPOS_PIXELS x, OLE_XPOS_PIXELS y) – a mouse button is released.

More:

Error codes


Error codes

The Property A2barcode1.ErrorCode AFTER A2barcode1.Caption has been set, may contain an error code if the component was unable to generate a barcode Picture. The property value will be one of the following:

0 No error
1 Wrong code length
2 Unrecognised code type
3 Invalid code data
4 Illegal character in code
5 Error in embedded code
6 Generated line width less than 1 unit

More:

Notes


Notes

More:

Macro sequences

Deutschepost and PostMatrix

GS1 Encoding

Truncated PDF417 symbols

Fixed size symbols

Unicode encoding


Macro sequences

Industry standard macro sequences may be used for DataMatrix, Maxicode and MicroPDF417 symbols, where the sequence [)> will be recognised automatically.

More:

Deutschepost and PostMatrix


Deutschepost and PostMatrix

Deutschepost Damatrix symbols for some applications are required to use Base256 encoding rather than the standard ECC200. The DL_DEUTSCHEPOST bit of the flag variable (bit 9 = 512) forces Datamatrix symbols to be encoded in this mode.

The PostMatrix variant of Datamatrix may be generated using the DL_POSTMATRIX bit of the flag variable (bit 6 = 64).

More:

GS1 Encoding


GS1 Encoding

Active Barcode Component 2D Universal Datamatrix and QR Code only

If the AztecMenu property is set to 2, the Caption string is scanned for GS1 Application Identifiers and encoded according to the GS1 Datamatrix or GS1 QR Code specification.

GS1 encoding requires the Application Identifiers to be provided within brackets, eg. (80)12345678(10)123456 so that the AIs can be identified.

Variable length AIs will have FNC1 characters inserted to terminate the AI and all brackets are removed from the encoded data.

For Datamatrix symbols only the Caption string property may begin with an FNC1 character - ASCII 232 (è) to force GS1 encoding; in this case it is not necessary to set the AztecMenu property.

During scanning FNC1 characters are replaced by ASCII values of 29.

More:

Truncated PDF417 symbols


Truncated PDF417 symbols

For PDF417 symbols setting the AztecFlag to 2 generates Truncated PDF417 symbols. Truncated symbols are recommended only for in-house applications because the truncation, while producing a smaller barcode, does remove the error checking characters and stop characters at the end of each row.

More:

Fixed size symbols


Fixed size symbols

The size of a symbol, expressed as number of columns (or dataword columns) rather than physical size, may be specified for Aztec (Full range mode), Datamatrix, PDF417, QR Code and DATABAR symbols by using the techniques described under the Columns property.

More:

Unicode encoding


Unicode encoding

Setting bit 7 of the AztecFlag property for the Aztec, Datamatrix, PDF417, QR Code and 2D Universal (for the Aztec, Datamatrix, PDF417, QR Code symbol types) components forces the component to encode that data as Unicode. Note that it is not necessary to set this bit for QR Code Kanji mode.

This is primarily useful for non-western character sets, and should not be used when encoding western characters because it will increase the size of the symbol.

More:

Visual FoxPro


Visual FoxPro

More:

On VFP Forms

Placing the control on the form

On VFP reports

Placing a picture control on the report

Specify the picture source


On VFP Forms

The Active Barcode Components may be added to VFP Forms in the same way as any other Active-X control.

More:

Placing the control on the form


Placing the control on the form

From the Form Controls toolbar select the "Active-X Control (OleControl)" icon.

Using the mouse with the left-button down draw a rectangle on the form where you wish the barcode to appear.

Release the mouse button and the Insert Object dialog appears.

Select the control you wish to use from the list of available controls and push the OK button.

Right-click on the control on the form and select “Properties” from the pop-up menu.

Locate the ControlSource property and set it to the desired data source (eg. table1.barcodedata)

Most other properties may be more conveniently set by right-clicking on the control and selecting "dLSoft Barcode Control object"....."Properties" from the pop-up menu; this results in the display of the control property pages.

More:

On VFP reports


On VFP reports

To include a barcode image on a report it is necessary to create a field in the underlying database to hold the barcode image for each record. This may be achieved by following the steps below then placing a picture control on the report and specifying the source of the picture as the barcode image field.

Add a field to a table to hold the barcode image - so give it a suitable name, such as "barcode".

Set the field type to General

More:

Placing a picture control on the report


Placing a picture control on the report

From the Report Controls Toolbar select the icon for "Picture/OLE bound control"

Using the mouse with the left-button down draw a rectangle on the report where you wish the barcode to appear.

Release the mouse button and the Properties dialog appears.

set the Control source type to "General field name"

set the Control source to the field you created above (eg table1.barcode)

Click on OK to close the Properties dialog.

More:

Specify the picture source


Specify the picture source

Right click on whitespace on the report

Select Data Environment from the pop-up menu - the Data Environment dialog appears.

Right click on the dialog's background and select Code from the pop-up menu.

A coding window appears.

Select the BeforeOpenTables procedure in the drop-down list at the top of the window.

Enter the following code into this window, being sure to set the ControlSource to the name you have chosen for the field in the table that holds the image, and that you set the properties required of the barcode (see below in red).

tfrm = createobject("Form")

with tfrm

.AddObject("BarcodeCtrl","OLEBoundControl")

.BarcodeCtrl.ControlSource = "table1.barcode"

scan all

APPEND GENERAL table1.barcode CLASS ("A2BARCODE.A2barcodeCtrl.4")

.BarcodeCtrl.Refresh

&& specify the properties for this barcode

.BarcodeCtrl.Object.FixSize = -1

.BarcodeCtrl.Object.CodeType = 1

.BarcodeCtrl.Object.Xunit = 40

.BarcodeCtrl.Object.Caption=table1.barcodedata

.BarcodeCtrl.Refresh

endscan

go top in table1

.BarcodeCtrl.Refresh

endwith

release tfrm

The code shown above is for 2D barcodes from Active Barcode Component Universal. For barcodes from other members of the Active Barcode Component family the CLASS should be the text specified in the right hand column of the table below:

Active Barcode component Universal (2D) | A2BARCODE.A2barcodeCtrl.4
Active Barcode component Universal (1D) | Axbarcode.Control.4
Active Barcode component Aztec | ABCAZT.AbcaztCtrl.4
Active Barcode component Databar | ABCRSS.AbcrssCtrl.4
Active Barcode component Datamatrix | ABCDMAT.AbcdmatCtrl.4
Active Barcode component PDF417 | ABCPDF.AbcpdfCtrl.4
Active Barcode component QR Code | ABCQR.AbcqrCtrl.4
Active Barcode component Standard | ABC39.Abc39Ctrl.4
Active Barcode component GS1 | ABCEAN.AbceanCtrl.4

That’s it. You are ready to preview the report.


Active Barcode Components

More:

Introduction

Using with CreateObject

Distributing Programs using Active Barcode Component

Using in VB6 and .NET

Using in Delphi

Using in C++ Builder

Using in a Container

Using in Access

Using in Word

Setting the image size

A Note on Metafile pictures

1D Component Reference

Error codes

2D Components

2D Component Reference

Error codes

Notes

Visual FoxPro