TBarCodeDLL�Board the Barcode Bandwagon
The barcode seems to be everywhere. From the little keychain tag that the checkout clerk zaps with a wand to the print-your-own-postage services such as stamps.com, barcodes have become an integral part of doing business. What is the attraction of these cryptic little buggers? Simple: you get fast, error-free data entry at 10 times faster than human input. If your products are ID-able, either uniquely (like a serial number) or non-uniquely (like a UPC code), you can reap great benefits from barcode integration.
In my other life, I'm an independent book publisher who lives or dies by the readability of my EAN Bookland barcodes. So I understand the importance of barcodes. And given that a barcode wand can be had for as little as $100, you have every reason to get on the barcode bandwagon too.
This article examines the TBarCode DLL component from Tec-It, a barcoding solution you can use to print reports or stickers that will verify inventory when scanned.
Tec-It and The Three Bars
TBarCode DLL is just one of a family of three barcoding solutions offered by Tec-It. The other two are TBarCode OCX and BarCode Studio. TBarCode OCX is a Microsoft ActiveX-compliant barcode control that combines all common linear and 2D barcodes (Code 39, Code 128, UCC/EAN Codes, Code 25 Interleaved, MaxiCode, PDF417, MicroPDF, Data Matrix (ECC200), QR-Code, Codablock-F, and many others) into one product. The OCX is .NET compatible and can be integrated into Microsoft Office products, ASP, Visual Basic, and other ActiveX-hosted environments.
TBarCode DLL offers all the same functionality as TBarCode OCX plus EAN/UCC Composite Symbology, MicroPDF, and all RSS Composite variants.
BarCode Studio is a complete end-user application for printing or exporting barcode images and is based on the Tec-It components.
Getting StartedHello Barcode!
Tec-It offers a downloadable evaluation version of TBarCode OCX, which includes help files and three sample programs in Visual C++ 6.0 project format. The Tec-It installer organizes icons and folders for all of these items. If that's not enough for you, you can download another set of about two dozen samples that highlight integration in various environments such as Crystal Reports, Internet Explorer 5, ASP, and other OCX hosts.
My first test was to load up the BarCode Viewer app ("BCVIEW") using Visual Studio 7.1. BCVIEW enables you to enter some piece of data and then display it on the screen, copy it to the clipboard, and/or save it as a bitmap type file. I entered the EAN-13 barcode for Beyond Trauma, 2nd Ed. (ISBN-13 data value 9781932690040), one of my own titles from 2005. The app compiled and ran with only a few minor compile warnings, and produced the following result:
Overall, the bitmap seems to be an exact duplicate of the one provided by Lightning Source Inc. for that book. The exception is that TBarCode didn't offer an option for embedding the price into the barcode.
Your First Barcode App
The demo program is nice, but let's see some source code and how it really works. Breaking it down to the simplest level, we will look at Tec-It's simplest provided C++ application. I'm a command-line kind of guy, so I used the following to compile and link in one step:
cl TBCDLLSample.cpp /Z7 /link /DEBUG TBarCode6.lib gdi32.lib user32.lib
Then, when I ran the app, the first thing it complained about was not finding TBarCode6.OCX. I located a copy of the OCX in the redist directory and punched in the OCX as follows:
regsvr32 Tbarcode6.ocx
This program is the smallest useful sample you can write. It performs the following tasks:
- Creates a Code128 barcode
- Draws the barcode onto a bitmap
- Burns the bitmap into a .JPG file
The following section goes through several areas of the program and makes some notes on what is happening in each:
1 // TBCDLLSample.cpp: Defines the entry point for the console
// application.
2 //
3
4 #include "stdafx.h"
5 #include <Windows.h>
6 #include <WTypes.h>
7
8 // include the header files for TBARCODE DLL
9 #define TECIT_DLLIMPORT
10 #include "TBarCodeDLL.h"
11 #undef TECIT_DLLIMPORT
12
13
14 /// include the tbarcode5.lib file to the linker section
15
16 //////////////////////////////////////////////////////////////
17 // TBarCode DLL Sample
18 //////////////////////////////////////////////////////////////
19 int main(int argc, char* argv[]) {
20 ERRCODE eCode = S_OK;
21 LOGFONTA* lf = NULL; // used to change font of barcode
22 t_BarCode* pBC;
23 char* szText;
24 INT nModules;
25
26 printf("TBarCode DLL Sample\n");
27 printf("-------------------\n\n");
28 printf("This program will create a sample barcode and save
it as \"c:\\bitmap.jpg\".\n");
29 printf("Barcode type: Code128\n");
30 printf("Encoded data: HELLO WORLD\n\n");
31
32 // License at startup of your application; get your license
// key from http://www.tec-it.com/order/
33 // BCLicenseMe( "Licensee String", // for enums refer to
// TECBCEnum.h
eKindOfLicense, 1, "Your Key", eProductID);
34
35 // allocate memory for internal barcode structure
36 BCAlloc (&pBC);
37
38 // set the barcode type to Code 128
39 // refer to TECBCEnum.h (or the documentation)
40 eCode = BCSetBCType (pBC, eBC_Code128);
41
42 if (eCode == S_OK) {
43 // set the barcode data to "HELLO WORLD"
44 szText = "HELLO WORLD";
45 eCode = BCSetText(pBC, szText, strlen(szText));
46
47 // change the font
48 lf = BCGetLogFont(pBC);
49 lf->lfHeight = 10;
50 strcpy(lf->lfFaceName, "Arial"); // face name must not
// exceed 31 characters
51
52 // Use this commands if you want to change the module width:
53 // BCSetModWidth (pBC, "254"); // Set module width to
// 0.254 mms
54 }
55
56 // check if the input data contains valid characters (for the
// selected barcode type)
57 if (eCode == S_OK)
58 eCode = BCCheck(pBC);
59
60 // compute the check digits (depends on barcode and CD-method)
61 if (eCode == S_OK)
62 eCode = BCCalcCD(pBC);
63
64 // prepare the internal barcode info-structure to be drawn
65 if (eCode == S_OK)
66 eCode = BCCreate(pBC);
67
68 // get number of horizontal barcode elements
69 if (eCode == S_OK)
70 nModules = (INT) BCGetCountModules (pBC);
71
72 // draw barcode to device context
73 if (eCode == S_OK) {
74 RECT rect;
75 HDC dc;
76 HBITMAP BM;
77
78 dc = CreateCompatibleDC(NULL);
79 BM = CreateCompatibleBitmap (dc, nModules * 2, 150);
// area of Pixels
80 SelectObject ( dc, BM );
81
82 rect.left = 0;
83 rect.bottom = 0;
84 rect.right = 5000;
85 rect.top = 3000;
86
87 SetMapMode(dc, MM_HIMETRIC);
88 OffsetRect(&rect,100, 100);
89
90 eCode = BCDraw(pBC, dc, &rect); // draw barcode into
// device context
91 DeleteObject (BM);
92 DeleteDC(dc);
93 }
94
95 // save barcode to image file
96 if (eCode == S_OK) {
97 // use number of horizontal elements as for the x dimension
// of the image
98 // this avoids aliasing effects and ensures readability of
// the barcode!
99 eCode = BCSaveImage(pBC, "c:\\bitmap.jpg", eIMJpg, nModules,
150, 96, 96);
100 }
101
102 // show error message on demand
103 if (eCode != S_OK) {
104 // if an error occurred, display more info about the error
105 char szErr[32] = {0};
106 //ZeroMemory(szText, sizeof(szText));
107 BCGetErrorText(eCode, szErr, sizeof(szErr));
108 MessageBox(NULL, szErr, "Error creating barcode:", MB_OK);
109 }
110
111 // Important: frees the allocated memory of the barcode
112 BCFree(pBC);
113
114 printf("done.\n");
115 return eCode;
116 }
Boost to Human Productivity
TBarCode DLL and OCX solve a complex problem with a simple interface. If you need to print reports or stickers that can be scanned in the field to verify the presence of a part or piece of inventory, the lowly barcode can be a big boost to human productivity and cut down on data-entry errors and operator fatigue.
About the Author
Victor Volkman has been writing for C/C++ Users Journal and other programming journals since the late 1980s. He is a graduate of Michigan Tech and a faculty advisor board member for Washtenaw Community College CIS department. Volkman is the editor of numerous books, including C/C++ Treasure Chest and is the owner of Loving Healing Press. He can help you in your quest for open source tools and libraries, just drop an e-mail to sysop@HAL9K.com.

Comments
Runabout 2013 a supplemental color drawing Nike Breath Max shoes
Posted by Tufffruntee on 04/24/2013 06:57amQualifying series Nike Breath Max HomeTurf city recently absolutely comes up, this series in the time-honoured Mood Max shoes to London, Paris and Milan [url=http://www.nikeskornatet.se/nike-free-50-v4-c-59/]nike free 5.0[/url] the three paid tribute to the iconic city of Europe, combined with the characteristics of the three cities, Manner Max 1 HYP,Current Max 90 HYP,Mood Max 1 and shoes such as Manner Max 95, combined with the Hyperfuse, as in all probability as a medley of materials, such as suede, Whether you lust after functional or retro-everything. It seems to me that more than Nike [url=http://www.nikeskorrea.se/nike-free-40-v2-c-20/]nike free 4.0 sverige[/url] shoes all supernova game sanctioned signature shoe series, and NSW series, all star color scheme of the chic Superciliousness Max Hyperposite exposure. Shaft daybreak brown provoked, hyperfuse, swoosh, and are married at the cessation of the yellow/orange gradient gap details, lining is a Galaxy in [url=http://www.nikeskorrea.se/nike-air-max-2013-c-28/]nike air max 2013[/url] orange follow garter, very beautiful.
Replycheap oakleys for sale
Posted by sgliliImpumpjrz on 04/01/2013 12:17pmhttp://discountsunglassesfinewebs.com - discount sunglasses oakley sunglasses cheap http://discountsunglassessale.webs.com - akley discount cheap oakleys http://guccisunglassescheap.webs.com - cheap ray ban sunglasses oakley sunglasses cheap http://cheapsunglassesshop.webs.com - cheap sunglasses,,, ray ban sunglasses cheap http://guccicheapsunglass.webs.com - cheap oakley oakley sunglasses cheap
Replyhttp://www.oakleysunglassesoutc.com/ skvgqg
Posted by http://www.oakleysunglassesoutc.com/ Suttonhsz on 03/28/2013 09:02amHanyang steel plant of Traffic to be convenient, but coal and iron ore to the sides do not rely on, and this is a big problem, Xiangshuai original 'big in China, He do not', so do not take seriously, K is not to learn this, although I think there is something wrong in mind, but do not say anything. Gu Hongming said some muffled. Townsend brother at least this also know, ghd hair straightener but know nothing about it! Tan Yankai said with a smile: ghd family native of Hunan, my father used on ghd straightener said, this Hunan and Hubei both coal and iron ore reserves are not very rich, ghd sale read this steel plant gas Bureau also think that the Huguang both the storage of coal and iron ore would be difficult to meet such a huge production of iron and steel enterprises. Happens to a few months ago ghd hair straightener in Hunan ways Jiangxi Pingxiang, heard of where there is a very rich reserves of coal mine, hastily written on, nor know Xiangshuai with unused, but to Xiangshuai a reference too!
Replyghd australia rrwewh
Posted by Mandyhut on 02/12/2013 02:18pm4wMie ugg sNwu oCgj nike shox sko 7bZln toms outlet 0cCxs hollister uk 9jNcv 0kZka sac longchamp 8yXwf louis vuitton outlet 0sAyn michael kors outlet 7zNho christian louboutin 3jKax Dashon Goldson Jersey 1qNjm 3aLoe 0kHxu ghd 2wQse ugg boots sale
Replyugg boots sxybon http://www.cheapfashionshoesas.com/
Posted by Mandyefm on 01/29/2013 04:03pm7rKnh nike outlet jJxa Michael Kors outlet oDxj ugg boots 4wLzx monster beats 6yOun NBA Miami Heat Snapback Grey Hat Wholesale Sell 8aMhj ugg norge 5oHey burberry outlet 9oGwl longchamp 0pEhu nike shoes online 5mChp cheap ugg boots 5aCrq monster beats 3aQms ugg 1xPnj ghd 3zZui 3bMnv
Replyugg boots aqcpbm http://www.cheapfashionshoesas.com/
Posted by Suttonero on 01/27/2013 03:26am4ePuh nike shoes cOlr Michael Kors outlet hLxm ugg boots 0rQls beats headphones 6xQbf Cheap nfl jerseys 1qUwo ugg sko 0xZrr burberry bags 9sNqc longchamp bags uk 4sDfx nike air max 4zJnq cheap ugg boots 7sQcz monster beats by dre 6mLvh ugg australia 7mOft ghd 7aIni 1vWoa
Replyugg boots udxvkt http://www.cheapfashionshoesas.com/
Posted by Suttonyyx on 01/26/2013 10:34pm2qXkx wKtd Michael Kors outlet hRmo ugg boots 1iSpr 7eCwg Cheap nfl jerseys 0tFex coach,coach outlet,coach usa,coach factory outlet,coach factory 4mGig burberry handbags 5lWng monster beats pas cher 8pNoo cheap monster beats 2nVqs 1nDgj 2bSiv 8vZqd 7eUfa 8vWpo
Reply2D barcode generator
Posted by fredle1 on 12/26/2012 12:14amCreate 2D barcode images in .net web applications. http://www.avapose.com/aspnet_barcode/2d_barcodes.shtml
Replylrxmgsbs avyqthsv http://frcadoudounemonclairpascher.webnode.fr/ rwocctto rokmkm
Posted by rootlyJerie on 11/15/2012 05:03amzlwcdk eetehh air jordan pas cher xjfmsogx air jordan suybxlk kmwjmkg kjdzc TBarCodeDLL�Board the Barcode Bandwagon yrcezyk abercrombie pas cher lvnqsqtv louboutin femme bvacbjwk sac longchamp soldes snoykxil
Replyjoyrhqvu pmupkzru http://www.jpshinjukubootsonlines.info uqhozcaj
Posted by Ralclabycer on 11/15/2012 01:40ammzvqr tpkue louis vuitton handbags genuine louis vuitton handbags outlet louis vuitton outlet las vegas osmjz mzwnlc TBarCodeDLL�Board the Barcode Bandwagon drkvxui beats by dre executive cheap beats dre cheap beats by dre a vibybbt hpltm coach outlet nj coach factory outlet coach handbags wholesale wopsjjxt christian louboutin shoes burlesque louboutin outlet usa louboutin outlet boutique hmkagyul
ReplyLoading, Please Wait ...