Chapter 9. QRCode ActiveX Reference

Many programming environments support the use of ActiveX objects. We have tested the Morovia QRCode ActiveX with Visual Basic, Visual C++, Internet Explorer, Microsoft Word, Excel, Access and IIS programs. The object can be used as a control embedded in a VB form or a dialog, or be used at background for image creation and printing purposes. The QR Code ActiveX object can also be inserted into Microsoft Office documents and many other ActiveX-aware programs.

9.1. Specification

Table 9.1. QRCode ActiveX Specification

Prog IDMorovia.QRCodeActiveX
ClassID{13C6D4E9-81BF-4BC6-B90E-B405CC3C0DC2}
Licensedno
File nameQRCodeCtrl.dll
InterfaceIQRCodeActiveX
Interface ID{5AF858A3-0D3E-4D8E-B22F-F8191C60C161}

9.2. Enumerations

Table 9.2. List of QRCode ActiveX Enumerations

NameDescription
QRTypeQRType Enumeration

9.3. Properties

Table 9.3. List of QRCode ActiveX Properties

NameDescription
ActualVersionReturns the actual version in the symbol created.
BackColorSpecifies the background color for the control.
ECLevelSpecifies the error correction level of the barcode generated.
ForeColorSpecifies the foreground color for the control.
MaskSpecifies the mask used to create final image.
ModuleSizeSpecifies the length of a module (the smallest unit in a QRCode barcode).
PictureReturns a snapshot of the drawing in Windows Enhanced Metafile Format (EMF).
QRTypeSpecifies the type of QR code to create.
TargetDPISpecifies the value of DPI when exporting the images to vector graphics.
TextSpecified the data to encode.
VersionSpecifies the desired version (size) of the barcode.

Table 9.4. List of QRCode ActiveX Methods

NameDescription
CopyToClipboardPlace the drawing to clipboard in EMF format.
ExportImageVectorExport image to a file in vector graphics format specified (EMF, EPS or SVG).
ExportImageRasterExport image to a file in raster graphics fromat specified (PNG or BMP).

9.4. ActualVersion Property

Description

Returns the actual version of the symbol created.

Syntax

object.ActualVersion 

Remarks

When Version specified is too small to encode the data, the program automatically select one that creates smallest barcode that fits. To find out the value of version realized, use this property.

9.5. BackColor, ForeColor Properties

Description

BackColor - returns or sets the background color of the control.

ForeColor - returns or sets the foreground color of the control.

Syntax

object.BackColor[= Color]
object.ForeColor[= Color] 

Remarks

For open systems we strongly recommend to set the background color to solid white (0xFFFFFF) and foreground color to black (0x000000). Note: barcode requires decent contrast between the foreground color and the background color in order to be readable. Always test the readability thoroughly when you select a color pair different from black and white.

9.6. ECLevel Property

Specifies the error correction level.

Syntax

object.ECLevel = Number

Description

QR Code employs Reed-Solomon error control coding to detect and repair errors. There are four user-selectable levels of error correction, as shown in the table below.

Table 9.5. ECLevel options

ValueDescriptionRecovery Capacity (approx.)
0Level L7%
1Level M15%
2Level Q25%
3Level H30%

9.7. Mask Property

Specifies the pattern to be used for data masking.

Syntax

object.Message[= Number] 

Description

For reliable QR Code reading, it is desirable for dark and light modules to be arranged in a well-balanced manner in the symbol. QR standard allows 7 patterns (000 - 111) to be used for data masking. If the value is -1, this program evaluates all seven patterns and select the one that produces the best result.

Table 9.6. Mask options

ValueDescription
-1Auto
0pattern 0 (000)
1pattern 1 (001)
2pattern 2 (010)
3pattern 3 (011)
4pattern 4 (100)
5pattern 5 (101)
6pattern 6 (110)
7pattern 7 (111)

9.8. ModuleSize Property

Description

Returns or sets a value that determines the width and height of a single cell in the QRcode symbols generated.

Syntax

object.ModuleSize[= String] 

Remarks

The real estate unit of a QR Code symbol, the module, is always square. This property sets both the width and the height of the square. It affects the overall symbol size.

The default value for ModuleSize is 20 mils. The property can be any numbers between 1 and 100.

This property is a string, and accepts the following units: mil, himetric, mm, cm, pt and inch. For example, 0.01cm and 1mm are all valid. If no measure unit is specified, unit of mil (which is 1/1000th inch) is assumed.

9.9. Picture Property

Description

Readonly property. Returns a snapshot of the drawing in Windows Enhanced Metafile Format (EMF).

Syntax

object.Picture

Remarks

The Picture property provides a convenient method to retrieve the drawing without first saving it to disk. The picture object contains an enhanced metafile handle which can be passed to clipboard or played on a device.

The included VC++ and C# examples use this property to retrieve an EMF handle and play it on the target printer to print the barcode.

9.10. QRType Enumeration

Specifies the type of the QRCode.

Syntax

typedef enum QRType {
  qrNormal = 0,
  qrHIBC   = 1,
} QRType; 

Constants

qrNormal
The normal QR Code.
qrHIBC

The data to encode is a HIBC LIC. The program will adds + and mod 43 checksum automatically and encode the whole into a QRCode.

qrMicro
The Micro QR Code.

9.11. QRType Property

Specifies the type of QR code. Currently it suports two types of QR Code symbols - normal QR and HIBC QR.

Syntax

object.QRType = Number 

Remarks

The defautl value of this property is QRNormal.

9.12. TargetDPI Property

Specifies the resolution of the target printer, applicable during exporting vector graphics.

Syntax

object.TargetDPI = Number 

Remarks

Whe producing small sizes of barcodes, especailly on lowe resolution printers, lengths must be align to the boundary of pixels in order to retain high quality. The ActiveX control adjusts the drawing units automaticaly based on this property when exporting vector graphics images.

9.13. Text Property

Specifies the Data to be encoded into the QR Code symbol.

Description

Returns or sets a string for the message to be encoded.

Syntax

object.Message[= String] 

Remarks

9.14. Version Property

Specifies the version of the symbol. The value ranges from 0 to 40. if the value is 0, the program select one that encodes the data and with minimum size.

Syntax

object.Version = Number 

Description

There are forty sizes of QR Code symbol rerferred to as version 1, Version 2 ... Version 40. Version 1 measures 21 modules x 21 modules, Version 2 measures 25 modules x 25 modules and so on increasing in steps of 4 modules per side up to version 40 which measures 177 modules x 177 modules.

When 0 is specified, the program selects a size that produces the most compact barcode that encodes the data.

Warning

If Version specified is too small to encode the data, the program automatically increase it to a value that is big enough. It means that the value of property will change every time the data is changed, if it is set to 0. Therefore, you must explicitely set it back to 0 you intend to use this value for creating the next QR code symbol.

9.15. CopyToClipboard Method

Copies the QRCode image into the system clipboard, in EMF format.

Syntax

obj.CopyToClipboard 

Description

Use this method to place a copy of barcode image to the clipboard, so that you can either retrieve it immediately in your application, or other applications such as Microsoft Word.

9.16. ExportImageRaster Method

Description

Exports the current drawing to a disk file, in raster image format (PNG or BMP).

Syntax

obj.ExportImageRaster(filename, Number, Number)

Parameters

pixelsPerModule

[in] Number of pixels per module.

imageType

[in] Image type. The current version supports two raster image formats:

  • 0 - PNG

  • 4 - BMP

9.17. ExportImageVector Method

Description

Exports the current drawing to a disk file, in raster image format (EMF, SVG and EPS).

Syntax

obj.ExportImageVector(filename, imageType) 

Parameters

imageType

[in] Image type. The current version supports two three image formats:

  • 1 - SVG

  • 2 - EMF

  • 3 - EPS