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



The best method to include barcodes in C/C++ projects is to use barcode images created as metafile images or enhanced metafile images. These provide the highest resolution image, and so the most accurate barcode. The dBarcode DLLs are dynamic link libraries that create high resolution metafile images (among others) for most major barcode types. A wide range of function calls is provided to allow the develop to retrieve a barcode image. Similar facilities are available in the dBarcode Developer kits, based on Active DLLs which also provide Active-X functionality and include the ability to create both image and font-based barcodes.
Using the call BarCodem() and BarCodemx() (for enhanced metafiles) will allow handles to these metafile images to be obtained directly.
Some developers may prefer (or be forced) to obtain the images from the clipboard (using BarCodec()) or from a disk file (BarCodef()). Others may be unable to use metafile images and be forced to use either monochrome bitmaps or device independent bitmaps, at the current default resolutions using calls to SetDpi, BarCodeb or BarCoded respectively, or at a specified target resolution in dpi using BarCodeb3 or BarCoded3 respectively. Barcode images may be save to disc in BMP, GIF, PCX, PNG or WMF formats.
The DLL can also draw the barcode image directly into a device context using one of the BarCodeh() calls.
The dBarcode DLL function calls are divided broadly into two classes. The Group 1 calls to the DLL require a Barcode structure to be filled prior to the call. The structure holds information about the barcode type, size, colour and data, etc.
Group 2 calls do not require the Barcode structure (unless a structure is being retrieved from the built-in dialog box functions), but do require the dialog box to be used to set barcode properties. The built in dialog box functions provide a simple way for a developer to allow the end user access to setting all barcode properties.

Group 1 calls allow the programmer to generate barcode from a Barcode structure. The prototypes of the library calls are:
LPHANDLE WINAPI BarCodem(HMODULE hInstance, LPRECT lpRectIn,
LPLOGFONT lpLogFontIn, LPBAR bc, LPHANDLE &hmf, LPSTR szPat)
where
hInstance is the instance (Module) handle of the calling application. This value
may be 0, but may alternatively be obtained by calling the GhDlsbar() function.
lpRectIn is a long pointer to a rectangle that is the destination rectangle for
the barcode image (with coordinates in units of 0.01 mm).
lpLogFontIn is a long pointer to a LOGFONT structure filled with information
about the font with which any text will be displayed on the barcode. The font
height will be treated as Points and treated as positive.
bc is a BARCODE structure - the LPBAR cast is required.
hmf is a HMETAFILEPICT handle that will contain the handle of the metafile image
on return.
szPat if a long pointer to a string that receives a pattern of 0s and 1s
representing spaces and bars respectively. This variable must be declared as
char szPat[4096];
before calling the library routines - even if you do not intend to use the
pattern. If your barcodes are not likely to exceed 12 characters in length, then
the pattern string may be declared as szPat[1024].
Calls to BarCodem create the barcode metafile image and the image pattern (for
developers who wish to draw their own bars), returning an error code in the
barcode structure in the event of an error.
An almost identical call is provided for creating enhanced metafiles:
LPHANDLE WINAPI BarCodemx(HCD hDCRef, HMODULE hInstance, LPRECT
lpRectIn, LPLOGFONT lpLogFontIn, LPBAR bc, LPHANDLE &hmf, LPSTR szPat)
where the only difference from Barcodem is the handle hmf and the handle
returned are HENHMETAFILE type (ie. refer to Enhanced metafiles).hDCRef is a
reference device context for the enhanced metafile; if hDCRef is NULL then the
default device context for the system will be used to create the enhanced
metafile.
int WINAPI BarInfo(HMODULE hInstance, int itype,LPBAR bc)
where
hInstance is the instance handle of the calling application. This value may be
0, but may alternatively be obtained by calling the GhDlsbar() function.
itype is the barcode type index (0-39), and
bc is a long pointer to a BARCODE structure.
Calls to BarInfo with an integer value specifying the barcode type in itype will
return bc containing information about that type, including its abbreviated
name, nominal length and height (if any), required number of characters (if
restricted), check digit (or parity) requirements, alphabetic character support,
and whether the code supports or requires a subscript (or supplementary code).
This information is useful for filling a listbox with the barcode type names,
and for checking whether a specific number of characters are required to
generate a valid code image.
BarInfo return a negative value when the code type specified by itype is
undefined.
int WINAPI BarCodeh2(HDC hDC, HANDLE hInstance, LPPOINT lpPt, LPSIZE
lpSz, LPLOGFONT lpLf, LPBAR bc);
where hDC is the target device context,
hInstance is the instance handle of the calling application (may be 0).
LpPt is a pointer to a POINT structure containing the coordinates of the top
left hand corner of the required target area (in the device coordinates) of the
device context.
LpSz is a pointer to a SIZE structure containing the x and y extents (in
HIMETRIC units - 0.01 mm) of the barcode image required. (Note that this may be
altered if an X unit value is specified in the spare element of the barcode
structure.)
LpLF is a long pointer to a LOGFONT structure filled with information about the
font with which any text will be displayed on the barcode. The font height will
be treated as Points and treated as positive.
Bc is a barcode structure.
int WINAPI BarCodeh3(HDC hDC, LPRECT lpr, LPLOGFONT lpLf, LPBAR bc,
BOOL bPrinting, int xRes, int yRes);
where hDC is the target device context,
lpr is a pointer to the target rectangle in HIMETRIC units
LpLF is a long pointer to a LOGFONT structure filled with information about the
font with which any text will be displayed on the barcode. The font height will
be treated as Points and treated as positive.
Bc is a barcode structure.
bPrinting is true if the output is to a printer or false otherwise
xRes and yRes are the horizontal and vertical resolutions of the target printer
int WINAPI BarInit(LPBAR bc)
Where bc is a barcode structure
For initialisation of the members of the barcode structure to default values
(code=8 – Code 39).
Barcodeb - returns the handle to a bitmap image
Barcoded - returns the handle to a device independent bitmap image.
Barcodec - produces barcode image on the clipboard for Visual Basic
Barcodef - saves the image of the barcode to disk
Barfinf - specifies the graphics formats in which barcode images may be saved to
disk.
BarcodeW - creates a barcode image on the Windows clipboard using a reduced (and
limited) set of data.
Barcodeh - display the barcode image within a device context.
BarCodep - generates only the pattern string (no graphic image)
BarCodeb3 - returns a handle to a bitmap image for a device of specified
resolution
BarCoded3 - returns a handle to a device independent bitmap for a device of
specified resolution
Group 2 calls enable the programmer to generate barcodes using a dialog box to provide the barcode properties rather than the Barcode structure.
BarAsk - displays a pop-up dialog requesting barcode information. When OK is
pressed all barcode properties except the data are stored in memory and saved as
defaults for future use.
BarAskEx - displays a pop-up dialog requesting barcode information. When OK is
pressed all barcode properties except the data are stored in memory and used as
defaults until the calling program is closed.
BarCdm - generates a metafile image from a data string using the current default
barcode properties.
BarCdmx - generates a enhanced metafile image from a data string using the
current default barcode properties.
BarCdd - generates a bitmap image from a data string using the current default
barcode properties.
BarCdh2 - draws a high-resolution image generated from the string parameter
using the current default barcode properties into the device context with the
handle hDC.
BarCdc - generates a enhanced metafile image from a data string using the
current default barcode properties and places the image on the clipboard.
BarCdcb - generates a bitmap (BMP) image from a data string using the current
default barcode properties and places the image on the clipboard.
BarCdcd - generates a Device Independent Bitmap (DIB) image from a data string
using the current default barcode properties and places the image on the
clipboard.
BarCdp - generates a barcode pattern string from a data string using the current
default barcode properties.
BarCds – generates a barcode image from a data string using the current default
barcode properties and saves the image to a named disk file.
BarCdrd - copies the current default barcode properties into a Barcode
structure.
BarCdin – sets the default barcode properties to the values passed as a Barcode
structure and saves the defaults for future use.
BarCdinEx – sets the default barcode properties to the values passed as a
Barcode structure; these values will be lost when the calling program is closed.