QRCode BarCode ActiveX Methods
|
AboutBox Method
Opens an About window.
Syntax
object.AboutBox
Return Value
No return value.
|
SaveToImageFile Method
Saves the image of the barcode to a file.
Syntax
object.SaveToImageFile(cx, cy, sFileName, [lRes,] [dm])
Parameters
cx | A double that defines the barcode picture width. |
cy | A double that defines the barcode picture height. |
sFileName | A string expression defining the file name. |
lRes | Optional (default 0). A long value that sets the picture resolution. |
dm | Optional (default qcPixels). This value defines the units that should be used to specify cx and cy. See remarks. |
Return Value
No return value.
Remarks
The format the file will be saved in depends on the extension of the file name For example, if you specify sFileName as "img1.jpg", the barcode will be saved as JPEG.
The following extensions can be used - "wmf", "emf", "bmp", "jpg", "jpeg", "gif", "tiff" and "png".
The dm parameter may has the following values:
qcMils = 0, mils(0.001 inches)
qcInches = 1, inches
qcMM = 2, millimeters
qcPixels = 3, pixels
If the size of an image (cx, cy) is not specified in pixels, its actual size will be calculated using
the specified picture resolution - lRes.
Warning! For this method to function properly, you should have the GDI+ library (gdiplus.dll)
installed on your PC, this library is distributed with Windows XP and higher. if you do not have this library,
you can download it here, and copy it to the
folder "../Windows/System32/".
Examples
'1. 'Save the image to a file of the JPEG format. The size of the image will be 100x100 pixels with the resolution of 96 dpi.
Call QRCodeCtrl1.SaveToImageFile(100, 100, "c:\qrcode.gif")
'2. 'Save the image to a file of the JPEG format. The size of the image will be 30x30 millimeters with the resolution of 300 dpi.
Call QRCodeCtrl1.SaveToImageFile(30, 30, "c:\qrcode.gif", 300, qcMM)
|
CopyToClipboard Method
Copies the image of the QRCode onto the clipboard. After that you can insert this image into your
program using Ctrl+V or the Paste menu item.
Syntax
object.CopyToClipboard(cx, cy)
Parameters
cx | An integer value that defines the barcode picture width |
cy | An integer value that defines the barcode picture height |
Return Value
No return value.
|
DrawMatrixToSize Method
Draws the QRCode barcode in the device context. You can use either printer or screen as the device context.
Syntax
object.DrawMatrixToSize(X, Y, CX, CY, dm, [hDC])
Parameters
X | A double value that defines the X coordinate of the barcode. |
Y | A double value that defines the Y coordinate of the barcode. |
CX | A double that defines the barcode width. |
CY | A double that defines the barcode height. |
dm | Optional (default qcPixels). This value defines the units that should be used to specify cx and cy. See here. |
hDC | Optional (default 0). The handle of the device context where the barcode will be drawn.
If this parameter is not specified or set to zero, the printer device context will be used. |
Return Value
No return value.
Examples
'Draw a QRCode matrix to a screen.
Call QRCodeCtrl1.DrawMatrixToSize(0, 0, 200, 200, qcPixels, Form1.hDC)
'Print a matrix 'Open a current printer
Call QRCodeCtrl1.BeginPrint("")
'print a matrix to X=10 mm, Y=10 mm, WIDTH=25 mm, HEIGHT=25 mm
Call QRCodeCtrl1.DrawMatrixToSize(10, 10, 25, 25, qcMM)
Call QRCodeCtrl1.EndPrint
|
BeginPrint Method
Opens access to a printer.
Syntax
object.BeginPrint(sPrinterName)
Parameters
sPrinterName | A string value that defines the name of the printer. The name of the printer can be determined in the Printer folder of the Control Panel.
If the name is blank, the default printer will be opened. |
Return Value
No return value.
Remarks
This function must be called first before other printing features are used.
|
EndPrint Method
Closes the printer. You cannot use any printing features after that.
Syntax
object.EndPrint()
Return Value
No return value.
|
NewPage Method
The StartPage function prepares the printer driver to accept data.
Syntax
object.NewPage()
Return Value
No return value.
|
EndPage Method
The EndPage function notifies the device that the application has finished writing to a page. This function is typically used to direct the device driver to advance to a new page.
Syntax
object.EndPage()
Return Value
No return value.
|
GetPrinterHDC Method
The function returns the handle of the printer previously opened with the help of the BeginPrint function.
Syntax
object.GetPrinterHDC()
Return Value
HDC
|
SetPrinterHDC Method
Defines the handle of the printer that will be used for printing. If this function is called, you
do not have to call BeginPrint. In this case the entire process of closing/opening the printer, etc.
will be controlled outside the QRCode ActiveX Control.
Syntax
object.SetPrinterHDC(hDC)
Parameters
hDC | Value that specifies the printer handle. |
Return Value
No return value.
Example
Printer.CurrentX = 2048
Printer.Print "BarcodeTools.com, VB Example"
'QRCode-ActiveX will use the Visual Basic Printer object
Call QRCodeCtrl1.SetPrinterHDC(Printer.hDC)
'print the barcodes
Call QRCodeCtrl1.DrawMatrixToSize(10, 10, 30, 30, qcMM)
Call QRCodeCtrl1.DrawMatrixToSize(70, 10, 30, 30, qcMM)
Printer.EndDoc
|
BinaryWritePicture Method
This method is similar to SaveToImageFile, but instead of saving the image to a file it represents it as a byte array.
Syntax
object.BinaryWritePicture(sFmt, CX, CY)
Parameters
sFmt | String that specifies the file name extension. The following extensions can be used - "wmf", "emf", "bmp", "jpg", "jpeg", "gif", "tiff" and "png". |
CX | A integer that defines the barcode width |
CY | A integer that defines the barcode height |
Return Value
Variant that specifies safe array of the bytes.
Remarks
This method can be useful for sending the image over the Internet. For example, it can be used by the IIS server.
Warning! For this feature to function properly, you should have the GDI+ library (gdiplus.dll) installed on your PC, this library is distributed with Windows XP and higher. if you do not have this library, you can download it here, and copy it to the folder "../Windows/System32/".
Example
<%
' we are sending a GIF image to the client
Response.ContentType = "image/gif"
Response.BinaryWrite qrcode.BinaryWritePicture("gif", 200, 200)
SET Barcode=nothing
%>
|
GetMatrixSize Method
This method calculates the matrix size needed to get the module of the necessary size.
Module is a single cell in a matrix symbology used to encode one bit of data.
Syntax
object.GetMatrixSize(module, xRes, yRes, dmIn, dmOut, width, height)
Parameters
module | A double that defines the matrix module. |
xRes | A long value that defines the resolution in dpi) along X axis. |
yRes | A long value that defines the resolution in dpi) along Y axis. |
dmIn | This value defines the units that should be used to specify module. |
dmOut | This value defines the units that should be used to specify width and height. |
width | A variable that receives the matrix width. |
height | A variable that receives the matrix height. |
Examples
Print QRCode with the module size of 40 Mils. The matrix must begin with X=10 mm, Y=10 mm
'open a current printer
Call QRCodeCtrl1.BeginPrint("")
'gets the printer resolution ( in dpi - dots per inch)
Dim dpiX As Long, dpiY As Long
dpiX = GetDeviceCaps(Printer.hdc, LOGPIXELSX)
dpiY = GetDeviceCaps(Printer.hdc, LOGPIXELSY)
'gets the required matrix width and height in units determined by the dmOut parameter
Dim Width, Height
Call QRCodeCtrl1.GetMatrixSize(40, dpiX, dpiY, qcMils, qcMM, Width, Height)
'prints the matrix
Call QRCodeCtrl1.DrawMatrixToSize(10, 10, Width, Height, qcMM)
'close the printer
Call QRCodeCtrl1.EndPrint
Save the matrix to a file so that the module is equal to 4 pixels.
'if dmIn and dmOut are specified in pixels, you do not have to specify the resolution (xRes, yRes), but it must not be equal to 0.
Dim Width, Height
Call QRCodeCtrl1.GetMatrixSize(4, 1, 1, qcPixels, qcPixels, Width, Height)
Call QRCodeCtrl1.SaveToImageFile(Width, Height, "c:\qrcode.bmp")
|
GetMatrixWidth Method
This method calculates only matrix width needed to get the module of the necessary size.
Syntax
object.GetMatrixWidth(module, xRes, yRes, dmIn, dmOut)
Parameters
module | A double that defines the matrix module. |
xRes | A long value that defines the resolution in dpi) along X axis. |
yRes | A long value that defines the resolution in dpi) along Y axis. |
dmIn | This value defines the units that should be used to specify module. |
dmOut | This value defines the units that should be used to specify width and height. |
Return value
QRCode width
See also
GetMatrixSize
|
GetMatrixHeight Method
This method calculates only matrix height needed to get the module of the necessary size.
Syntax
object.GetMatrixHeight(module, xRes, yRes, dmIn, dmOut)
Parameters
module | A double that defines the matrix module. |
xRes | A long value that defines the resolution in dpi) along X axis. |
yRes | A long value that defines the resolution in dpi) along Y axis. |
dmIn | This value defines the units that should be used to specify module. |
dmOut | This value defines the units that should be used to specify width and height. |
Return value
QRCode height
See also
GetMatrixSize
|
GetRawMatrix Method
This method returns 2D array that represent image of QRCode symbol. Developers can use this method like they want (use in own draw methods, save QRCode in database, etc.)
Syntax
Matrix = object.GetRawMatrix
Return Value
2D matrix that contains 1 or 0 values depends dark or light module.
|