Часто задаваемые вопросы: TBarCode DLL / TBarCode Library
Отрисовка в Bitmap-DC и масштабирование в Screen-DC
Отрисовка в Bitmap-DC и масштабирование в Screen-DC
DrawBarcode (HDC hDC, long xpos, long ypos)
{
RECT hRect;
long lHRHeight = 0;
ypos += GetFullHeight();
hRect.left = xpos;
hRect.top = ypos;
hRect.right = hRect.left + width;
hRect.bottom = hRect.top + height;
HDC memDC;
HBITMAP memBMP, oldBMP;
int width, height;
RECT draw;
width = abs(hRect.right - hRect.left);
height = abs (hRect.bottom - hRect.top);
draw.left = 0;
draw.bottom = height;
draw.top = 0;
draw.right = width;
memDC = CreateCompatibleDC(hDC);
memBMP = CreateCompatibleBitmap(hDC, width, height);
oldBMP = (HBITMAP) SelectObject(memDC, memBMP);
if (S_OK = BCDraw(pBarcode, memDC, &draw))
{
// scale / copy to target DC
BitBlt(hDC, hRect.left, hRect.top, width, height, memDC, 0, 0, SRCCOPY);
SelectObject(memDC, oldBMP);
}
DeleteObject(memBMP);
DeleteDC(memDC);
}