TBarCode OCX 11 Developer Manual
TBarCode OCX 11 Developer Manual
V ers io n 1 1
Developer Manual
6 M arc h 20 1 5
T EC- IT Da te n v er arb e it un g G m bH
Ha ns -W agner - Str . 6
A- 44 0 0 S te yr , A us t ri a
t + + 43 ( 0)7 2 52 72 7 20
f + + 43 ( 0)7 2 52 72 7 20 77
of f ic e @ tec - i t.c om
ww w. tec - i t.c om
T Bar Cod e O C X D ev e l ope r M anu a l
1 Content
1 Content 2
2 Disclaimer 3
3 Introduction 4
3.1 What is TBarCode SDK? 4
3.2 Important Security Notice 4
3.3 What is TBarCode OCX? 4
3.4 Scope of this Document 4
3.5 Restrictions of the Demo Version 5
4 Installation 6
4.1 Requirements 6
4.2 Download and Setup 6
5 Microsoft Development Environments 7
5.1 Microsoft Visual Basic 6 7
5.2 Microsoft Visual C++ 7
5.2.1 MFC Applications 7
5.2.2 Non MFC Application 9
5.3 Microsoft .NET 10
5.3.1 Use TBarCode OCX as Control 10
5.3.2 Use TBarCode OCX as Library 11
5.4 Microsoft Visual FoxPro 12
5.4.1 Inserting TBarCode into a FoxPro-Project 12
5.4.2 Reports & Labels 12
6 Microsoft ERP Systems 13
6.1 Microsoft Navision® / Dynamics® NAV 13
7 Borland Delphi / Borland C++ Builder 14
7.1 Using TBarCode OCX in Borland Delphi 6/7 14
7.2 Using TBarCode OCX in Borland Delphi 2005 (Delphi for Win32) 14
7.2.1 Create and Save a Package for TBarCode OCX 14
7.2.2 Set the Project Options 14
7.2.3 Import TBarCode Component 15
7.2.4 Add Components to the Package 16
7.2.5 Create and Install Package 16
7.2.6 Create a new VCL Forms Application 16
8 Sybase PowerBuilder 17
8.1 TBarCode OCX in PowerBuilder DataWindow 17
8.2 Insert TBarCode OCX 17
8.3 Script the Control within PowerBuilder 10 18
8.4 Generate Barcode Images for the DataWindow 18
8.4.1 Generate the Barcode Images (from the Dialog Window) 18
8.4.2 Insert the Barcodes into your DataWindow 18
9 Oracle Forms / Oracle Reports 20
9.1 Barcodes in Forms 20
9.2 Barcodes in Reports 20
10 Redistributing TBarCode OCX 21
10.1 Dependencies 21
10.2 Redistribution 21
11 Contact and Support Information 23
Appendix A : FAQ 24
A.1 How to set a specific Module Width (15 mils) in Web Applications? 24
A.2 License TBarCode in my Application 24
A.3 Clipped Barcode Image (SaveImage) 24
A.3.1 Solution 24
A.4 Unreadable Barcodes with PrintForm (VB) 24
A.5 Save MaxiCode with a higher Resolution 25
A.6 SaveImage does not work 25
A.7 Barcodes created with SaveImage are unreadable 25
A.8 Additional FAQs on our Web Page 25
Page 2 of 25
T Bar Cod e O C X D ev e l ope r M anu a l
2 Disclaimer
The actual version of this product (document) is available as is. TEC-IT declines all warranties that
go beyond applicable rights. The licensee (or reader) bears all risks that might take place during the
use of the system (the documentation). TEC-IT and its contractual partner cannot be penalized for
direct and indirect damages or losses (this includes non-restrictive, damages through loss of
revenues, constriction in the exercise of business, loss of business information or any kind of
commercial loss), which is caused by use or inability to use the product (documentation), although
the possibility of such damage was pointed out by TEC-IT.
We reserve all rights to this document and the information contained therein. Reproduction,
use or disclosure to third parties without express authority is strictly forbidden.
Für dieses Dokument und den darin dargestellten Gegenstand behalten wir uns alle Rechte
vor. Vervielfältigung, Bekanntgabe an Dritte oder Verwendung außerhalb des vereinbarten
Zweckes sind nicht gestattet.
© 1998-2015
TEC-IT Datenverarbeitung GmbH
Hans-Wagner-Str. 6
A-4400 Austria
t.: +43 (0)7252 72720
f.: +43 (0)7252 72720 77
http://www.tec-it.com
Page 3 of 25
T Bar Cod e O C X D ev e l ope r M anu a l
3 Introduction
TBarCode SDK is available in several versions for different operating systems, applications and
programming environments. The following versions are included in this setup:
TBarCode OCX A Microsoft® ActiveX® compliant barcode control. It can be used with
Microsoft® Office applications as well as by software developers.
TBarCode .NET A .NET barcode library for software developers. It includes barcode
controls for Windows Forms and ASP.NET 2.0.
TBarCode Library A DLL for Windows platforms for software developers.
(A DLL for Windows CE/Windows Mobile is available on request. Please
contact us with your platform details.)
► The ActiveX control TBarCode OCX is now a site-locked ActiveX control. This security
enhancement was implemented in response to a reported possible security leak in conjunc-
tion with Internet Explorer and an installed TBarCode OCX. It is strongly recommended to
update all TBarCode installations as soon as possible.
As part of the fix the TBarCode OCX methods SaveImage() and SaveImageEx() now are
restricted to specific internet zones. This happens only if TBarCode OCX runs in Microsoft
Internet Explorer as part of a web-page. The allowed zones can be specified in the registry.
In addition these functions append the correct image filename extension if the file extension
specified by the user does not match the supported image formats.
Please refer to the TBarCode OCX Developer Reference for details.
Microsoft® Office: barcodes are embedded into documents, forms or databases easily.
Development environments: integrate barcodes into your own application(s).
Report-Generators and Reporting Engines: Enhance the output with barcode functionality.
Web Applications: Use barcode technique as part of browser-based applications.
Most programming and script languages.
Page 4 of 25
T Bar Cod e O C X D ev e l ope r M anu a l
In the demo version the barcodes will be drawn with a demo-hint. That means that the word “Demo”
or the phrase “www.tec-it.com” is drawn partially over the barcode. The demo-hint does not influ-
ence the readability of the barcode in a negative way.
► In special cases (e.g. very small or high-resolution barcodes) you may want to test the pro-
duct without restrictions. To obtain a temporary license key contact sales@tec-it.com.
► For enabling the full-featured version (without the demo hints) you can obtain a license key
from TEC-IT (http://www.tec-it.com/order/).
► For more information on licensing TBarCode, please refer to section A.2.
Page 5 of 25
T Bar Cod e O C X D ev e l ope r M anu a l
4 Installation
4.1 Requirements
TBarCode OCX
A barcode ActiveX control for Microsoft Office users and for software developers. User
manual and API reference are included in the setup.
TBarCode Library
A DLL for software developers. Developer manual and API reference are included in the
setup.
TBarCode .NET
For software developers. Developer manual and API reference are included in the setup.
Page 6 of 25
T Bar Cod e O C X D ev e l ope r M anu a l
In order to insert TBarCode OCX in Visual Basic 6, please execute the following steps:
Page 7 of 25
T Bar Cod e O C X D ev e l ope r M anu a l
The control is thereafter selectable in the control toolbox in the dialog editor ().
Page 8 of 25
T Bar Cod e O C X D ev e l ope r M anu a l
Page 9 of 25
T Bar Cod e O C X D ev e l ope r M anu a l
In order to use TBarCode OCX in Visual Studio .NET (e.g. in a “Windows Forms Application” or in
an “ASP .NET Web Forms Application”), please follow these steps:
Microsoft Visual Studio automatically generates a wrapper class for an existing ActiveX control. You
can use it like any other control in .NET.
Page 10 of 25
T Bar Cod e O C X D ev e l ope r M anu a l
In order to use TBarCode per code only (without embedding it as ActiveX control in a form), please
follow these steps:
Page 11 of 25
T Bar Cod e O C X D ev e l ope r M anu a l
In order to insert TBarCode in Visual FoxPro, please execute the following steps:
If you want to print barcodes in reports or labels, you need a table with a specific column, in which
TBarCode must be stored as OLE Control (data type “general”). This data field must be initialized
with the data structure of a barcode object before use. For this purpose you need an instance of a
TBarCode object as template (e.g. on a form, it may be invisible).
Example code for the initialization of the data fields of a barcode object:
FOR n = 1 TO 10
INSERT INTO Table1 FROM MEMVAR
APPEND GENERAL Table1.BC CLASS TBarCode11.TBarCode11
WITH THISFORM.[Name of the TBarCode object instance]
.CONTROLSOURCE = "Table1.BC"
.REFRESH
.barcode = 20 && Barcode-Type = Code128
.TEXT = "000070000041"
.printdatatext = .T.
.BACKCOLOR = 16777215
.FORECOLOR = 0 && 16711680 -> (blue)
.REFRESH
ENDWITH
NEXT
After this code has been executed, an OLE Picture/ActiveX Bound Control can be inserted into a
Report or Label Form. In this sample, you have to specify "Table1.BC" as data source (field).
Please take a look at our FoxPro-Sample, which can be downloaded from http://www.tec-
it.com/Download ► TBarCode.
Page 12 of 25
T Bar Cod e O C X D ev e l ope r M anu a l
For more detailed information, please take a look at our Navision Tutorial, which can be down-
loaded under http://www.tec-it.com/Download ► TBarCode or contact our technical support.
Page 13 of 25
T Bar Cod e O C X D ev e l ope r M anu a l
7.2 Using TBarCode OCX in Borland Delphi 2005 (Delphi for Win32)
Save Package:
Choose File ► Save All from the menu.
The Save Package As dialog will open.
Choose the directory for saving the package.
Hint: It is recommended to create a separate
directory for the package.
Then assign a name to package-project (e.g.
TBarCode11).
Confirm with OK.
Description:
Select Description in the tree on the left. The
description text can be edited on the right.
Output Directory:
Select Directories/Conditionals in the tree on
the left.
Under Output directory, choose the directory
where you have saved your project.
Confirm with OK.
Page 14 of 25
T Bar Cod e O C X D ev e l ope r M anu a l
Page 15 of 25
T Bar Cod e O C X D ev e l ope r M anu a l
Page 16 of 25
T Bar Cod e O C X D ev e l ope r M anu a l
8 Sybase PowerBuilder
To get dynamic “data driven” barcodes you have to use the following workaround.
Instead of placing the TBarCode OCX control inside the DataWindow, you have to insert it into
the dialog Window. Thus it can be programmed for our workaround as follows.
By using this control you can create a bitmap file for each barcode, save it to disk and load it to a
picture data field in the DataWindow. That has to be done for each data row/record set.
This workaround is described in detail in the following sections.
To insert TBarCode OCX into a PowerBuilder dialog window, please execute the following steps:
► In PowerBuilder Version 7, 8, 9 and 10 always insert TBarCode with Insert Control because
Create New does not work with scripting.
1
PowerBuilder version 7-10
Page 17 of 25
T Bar Cod e O C X D ev e l ope r M anu a l
In order to access the properties and methods of the ActiveX control you have to use the following
syntax:
ControlName.Object.Property
Example:
ole_1.object.text = "hello"
ole_1.object.barcode = 20 ' 20 = Code 128
► The barcode type (the symbology) is set by assigning a number to the barcode property.
Please refer to the "Barcode Reference" (http://www.tec-it.com ► Support ► Knowledge
Base) to learn more.
You need a TBarCode OCX object in your dialog window which can be programmed. In our sample
it is called “w_barcode_printing”.
Open your source code. In the section where you prepare the data for the output you have to do
something like the following to save the barcode images:
//Image path and filename
ls_image = "C:\_APPS\FeeSystem\bc1.jpg"
► Currently PowerBuilder only supports BMP, JPEG, and GIF. You cannot use the EMF file
type.
With the SetItem() function you can finally assign the name of the generated barcode bitmap file to
the column used in the DataWindow (bc_pic).
Using this approach will allow you to simulate the data binding inside the DataWindows.
Inside your DataWindow you have to create a column with a STRING data type. Here we use the
name bc_pic. This column will contain the path and the name for each barcode bitmap file for each
record. Then insert a column control for the created data field.
In the “General” properties of the column control check the DISPLAY AS PICTURE box as shown
below. This will make the control show the picture and not the filename inside the control frame.
For example: If the column contains the value “c:\picture.jpg”, the control will display the picture
and not the text “c:\picture.jpg”.
Page 18 of 25
T Bar Cod e O C X D ev e l ope r M anu a l
Instead of using a column control you may also insert a computed field control and use the
BITMAP() function:
Page 19 of 25
T Bar Cod e O C X D ev e l ope r M anu a l
In order to use TBarCode OCX in an Oracle Form please execute the following steps:
Optional:
Create a button and add a when-button-pressed trigger on the canvas (where you can call
the ActiveX control).
Close the layout editor (This step is VERY IMPORTANT!).
Run the form.
Press the button to run the ActiveX control.
Workaround: The user can call an executable from within a report. For instance you can generate
barcode bitmaps with the TEC-IT product Barcode Studio which can be executed in command line
mode (without a visible window). Barcode Studio creates and saves a bitmap whenever it is called.
Afterwards the generated bitmap can be loaded into an image inside the report.
Another possibility is to use the TFORMer product family (advanced label and form reporting tool).
Use TFORMer Designer to design your barcode label or report. Thereafter use TFORMer Runtime
(or the command line tool TFPrint.exe) to generate and print the complete report. TFORMer
supports direct printer output, PostScript, PDF and HTML output directly (without any additional
software).
Page 20 of 25
T Bar Cod e O C X D ev e l ope r M anu a l
This chapter explains what is important when redistributing a custom application that uses the
TBarCode OCX control.
► Please note that in most cases you need a developer license for re-distribution of TBarCode
OCX (except for in-house applications which are bound to one or more sites).
10.1 Dependencies
TBarCode11.ocx
This is the native Win32 ActiveX component. This file is mandatory.
TBarCode11_x64.ocx
This is the native Win64 (x64) ActiveX component. This file is mandatory.
TBarCode11.dll
This is a native Win32 library that performs barcode generation. This file is mandatory.
TBarCode11_x64.dll
This is a native Win64 (x64) library that performs barcode generation. This file is mandatory
for 64-Bit applications.
zlib1.dll
This is a 3rd-party library that performs data compression. This file is optional. It is only
required, when data compression in barcodes is enabled.
These files are located in the folder C:\Program Files\Common Files\TEC-IT\TBarCode\11.0 (or in
the folder you have chosen during setup).
TBarCode OCX requires also the Microsoft VC100 CRT and ATL DLLs. See next section how to
distribute them with your application.
10.2 Redistribution
When redistributing a custom application the files described above need to be redistributed together
with the application. The DLLs should be located in the same folder as the executable.
You may have to redistribute the Visual C++ 2010 SP1 runtime components (MS CRT 10.0 and
ATL 10.0 DLLs) with your application and ensure they are installed on the target computer.
There are two options to install the redistributables for the Win32 version:
You can install these components with the Microsoft Visual C++ 2010 SP1 Redistributable
Package available at
- 32 Bit (x86) version: http://www.microsoft.com/en-us/download/details.aspx?id=8328
- 64 Bit (x64) version: http://www.microsoft.com/en-us/download/details.aspx?id=13523
The package installs all required runtime DLLs.
If you use a setup tool and your installer supports merge modules (*.msm files) you can add
the required msm packages to your setup:
32 Bit (x86)
- Microsoft_VC100_CRT_x86.msm
- Microsoft_VC100_ATL_x86.msm
Page 21 of 25
T Bar Cod e O C X D ev e l ope r M anu a l
- 64 Bit (x64)
- Microsoft_VC100_CRT_x64.msm
- Microsoft_VC100_ATL_x64.msm
Page 22 of 25
T Bar Cod e O C X D ev e l ope r M anu a l
Address: Hans-Wagnerstr. 6
AT-4400 Steyr
Austria/Europe
Phone: +43 / (0)7252 / 72 72 0
Fax: +43 / (0)7252 / 72 72 0 – 77
Email: mailto:support@tec-it.com
Web: http://www.tec-it.com
FAQ: http://www.tec-it.com/support/faq/tbarcode/Default.aspx
All other products mentioned are trademarks or registered trademarks of their respective companies. If any trademark on our web site or in this
document is not marked as trademark (or registered trademark), we ask you to send us a short message (mailto:office@tec-it.com).
Page 23 of 25
T Bar Cod e O C X D ev e l ope r M anu a l
Appendix A: FAQ
If you have questions not covered in these FAQ, you can also check our website http://www.tec-
it.com/FAQ or contact our support team: mailto:barcode@tec-it.com.
A.1 How to set a specific Module Width (15 mils) in Web Applications?
Please refer to the "Barcode Reference" (http://www.tec-it.com ► Support ► Knowledge Base) for
more information.
Now implement a call to the method LicenseMe before you draw a barcode (we suggest at startup
of your application).
The Product ID depends on the version of TBarCode (see your license data).
A.3.1 Solution
If you need a specific module width for your application (e.g. 3 pixels), use the number of barcode
modules (CountModules property) and multiply this value with 3 (to get 1 module = 3 Pixels wide).
Use this value as horizontal size of the image in SaveImage. Using this method, the image size will
adapt automatically depending on number of horizontal barcode modules.
For 2D symbologies use Get2DXCols and Get2DXRows for finding the best horizontal and vertical
size values.
To work around this problem adjust the module width of the barcode to the resolution of the screen:
Page 24 of 25
T Bar Cod e O C X D ev e l ope r M anu a l
For details please see our Visual Basic Sample Code, which is installed together with the product
setup. The samples contain also the PrintForm workaround to get a readable barcode.
Example:
FlName = "Maxicode.bmp"
TBarCode111.Text = "BarCodeText"
TBarCode111.BarCode = eBC_MAXICODE
'Use nRatio to enlarge or reduce image size
nRatio = 2
TBarCode111.ModuleWidth = 1500 * nRatio
DoEvents
YSize = 208 * nRatio
XSize = 215 * nRatio
TBarCode111.SaveImage "C:\Users\User\Documents\" & FlName, TBarCode11Lib.eIMBmp, XSize,
YSize, 72, 72
'Hint : When printing we recommend using the standardized size of MaxiCode
'Height: ~24.4 mms;
'Width : ~25,2 mms
Please check if you have write permissions to the directory you want to write to (e.g. important in
web applications).
Please check if the internet zone was unlocked when using TBarCode OCX as part of a web page.
See the TBarCode OCX Developer Reference for details.
Page 25 of 25