Calls to Bar2Dh draw the barcode image into the specified device context, rather than creating a metafile image. Apart from that the parameters are as defined for Bar2Dm.
int WINAPI Bar2Dh(HDC hDC, HANDLE hModule, LPRECT lpRectInL, LPBAR2D bc, LPSTR szPat);
where
hDC is the target device context
hModule is the Module handle of the calling application.
lpRectIn is a long pointer to a rectangle that is the destination rectangle for the barcode image. . If all coordinates of the rectangle are provided these should be in Device coordinates and the image fits within the rectangle. If the rect.right value is 0, then the top and left coordinates are taken to be in HIMETRIC units (0.01 mm), measured from the top left of the device context, and the image is rendered using the size determined from the xunit and yunit values (specified in Mil units - 0.001 inch).
Users of the MFC Print Preview facility should note that scaling is required when using this call. Bar2Dm is simpler to use for this purpose.
bc is a BARCODE2D structure - the LPBAR2D cast is required.
szPat if a long pointer to a string that receives a pattern of 0s and 1s representing spaces and bars respectively. This variable must either be declared as
char szPat[4096];
before calling the library routines - or passed as NULL – in which case no pattern is returned. For very large barcodes it may be necessary to increase the size of this buffer to 8k or even 16k. For information on the pattern string see the 2D Barcodes Help file.
Calls to Bar2Dh 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 barcode2d structure in the event of an error.
The following sample code shows a call to Bar2Dh to display the barcode image on the device specified by pDC within the rectangle defined by CliRect (the client rectangle of a Window).
// CliRect is target rectangle in device coordinates
GetClientRect(&CliRect)
Bar2Dh(pDC->m_hDC,GhDlsbar2D(), &CliRect,,(LPBAR2D)&bc,(LPSTR)szPat);
int WINAPI Bar2Dh2(HDC hDC, HANDLE hModule, LPPOINT lp, LPBAR2D bc)
Calls to Bar2Dh2() are similar to Bar2Dh() except that the lp parameter points to the coordinates of the top left-hand corner of the image in device coordinates, and the size of the image is determined by the values specified in the bc structure.
More: