Calls to BarCodeh draw the barcode image into the specified device context, rather than creating a metafile image. Apart from that the parameters are as defined for BarCodem.
int WINAPI BarCodeh(HDC hDC, HMODULE hInstance, LPRECT lpRectIn, LPLOGFONT lpLogFontIn, LPBAR bc, LPSTR szPat);
where
hDC is the target device context
hInstance is the instance handle of the calling application (may be 0).
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.
szPat is 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 BarCodeh draws the barcode image on the specified device context and returns the image pattern (for developers who wish to draw their own bars or derive information about the number of elements), returning an error code in the barcode structure in the event of an error.
The following sample code shows a call to BarCodeh to display the barcode image on the device specified by hDC within the rectangle defined by lpRect (the device context in this example is in MM_ISOTROPIC mode and uses logical units of 0.01 mm with the Y value increasing DOWN the page. Your starting point may be different.).
// lpRect is target rectangle in logical coords i.e.
0.01 mm
CopyRect(&tRect,lpRect);
LPtoDP(hDC,(LPPOINT)&tRect,2);
SaveDC(hDC);
SetMapMode(hDC,MM_ANISOTROPIC);
SetWindowOrg(hDC,0,0);
SetViewportOrg(hDC,tRect.left,tRect.top);
SetViewportExt(hDC,tRect.right-tRect.left,
tRect.bottom-tRect.top);
BarCodeh(hDC,0,lpRect,&logfont,(LPBAR)&bc,(LPSTR)szPat);
RestoreDC(hDC,-1);
More: