|
FAQ: TBarCode DLL | | | | | | FAQ TBarCode DLL: How to Use Custom Drawing (Callback) in VB, Drawing to Bitmap-DC and Scaling to Screen-DC | | Â |
Visual Basic Code Sample |  | How to Use Custom Drawing (Callback) in VBTBarCode V6
'callback function
Public Function MyDrawRow ( ByRef pMyData As Long,
ByVal pBarCode As UIntPtr, ByVal hDC As IntPtr,
ByVal hTargetDC As IntPtr,
ByRef pRect As Rectangle) As UInt32
Dim strTempo As String
strTempo = TBC6.BCGetMetaData(pBarCode)
Return Convert.ToUInt32(0)
End Function
'setting the address of the callback function
Public cb As TBC6.Callback
cb = AddressOf MyDrawRow
eCode = TBC6.BCSetFuncDrawRow(hBarcode, cb, pData)
'required declarations
Declare Ansi Function BCDrawCB Lib "TBarCode6.ocx" ( _
ByRef hBarcode As UIntPtr, _
ByVal hDC As IntPtr, _
ByRef pRect As Rectangle, _
ByVal func As Callback, _
ByVal func As Callback, _
ByVal pData As IntPtr ) As Int32
Declare Ansi Function BCGetMetaData Lib "TBarCode6.ocx" ( _
ByVal hBarcode As UIntPtr ) As String
| |
C++ Code Sample |  | Drawing to Bitmap-DC and Scaling to 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);
}
| |
|
|
© TEC-IT Datenverarbeitung GmbH, Austria ++43(0)7252/72720 office@tec-it.com |
|
|