Click here to Skip to main content
15,887,967 members
Articles / All Topics

Barcode Reader Demo

Rate me:
Please Sign up or sign in to vote.
3.67/5 (2 votes)
4 Jan 2010CPOL 22.2K   11   2
Attached is a demo application showing some aspects of barcode scanning in C# on ITC devices.

Attached is a demo application showing some aspects of barcode scanning in C# on ITC devices. The demo source is written against CF2 and needs the right ITC datacollection runtime installed.

Datacollection runtimes (DC_NET.CAB) location:

+---WCE300
¦ +---Pocket PC 2002
¦ +---Arm
¦ +---X86
+---WCE420
¦ +---CV60
¦ ¦ +---X86
¦ +---iCE-Premium
¦ ¦ +---Armv4i
¦ +---iCE-Standard
¦ ¦ +---Armv4i
¦ +---Pocket PC 2003
¦ +---Armv4
¦ +---emulator
+---WCE500
¦ +---iCE50-CK60-A4i
¦ ¦ +---Armv4i
¦ +---ITC_CE5.0
¦ ¦ +---Armv4i
¦ +---WM5.0
¦ +---Armv4i
+---WCE600
¦ +---WM6
¦ +---Armv4i
+---XP

Here are some screens of ScanDemo:

ScanDemo5

The main code is the barcode read event handler. You have to wrap GUI updates in Delegate/Invoke or you will get problems earlier or later.

C#
/*$6
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
*
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
*/

void BarcodeReader_BarcodeRead 
	( object sender, Intermec.DataCollection.BarcodeReadEventArgs bre )
{
brc = bre;
try
{
this.Invoke( new EventHandler(UpdateListBox) );
}
catch
{
}
}
/*
------------------------------------------------------------------------------------------
*
------------------------------------------------------------------------------------------
*/
protected void UpdateListBox( object sender, EventArgs e )
{
String  s;
string  sh;
String  t;
if ( brc.Symbology > 0 && brc.Symbology < 0x20 )
{
t = bctype[brc.Symbology];
}
else
{
t = "n/a " + brc.Symbology.ToString();
}
s = "*" + brc.strDataBuffer + "* - " + t;
/* convert control codes */
byte[] ba;
ba = brc.DataBuffer;
sh = s;
try
{
sh = HexEncoding.ToMixedString( ba );
}
catch( Exception ex )
{
System.Diagnostics.Debug.WriteLine( ex.Message );
}
if ( bUseHexMode )
{
s = sh; /* use the hex mangled string */
}
/* add the data to display */
if ( bUseListMode )
{
lblBarcode.Items.Add( s );
lblBarcode.SelectedIndex = lblBarcode.Items.Count - 1;
}
else
{
txtBarcode.Text = s;
}
}
<!-- Social Bookmarks BEGIN --> <!-- Social Bookmarks END -->
This article was originally posted at http://www.hjgode.de/wp/2009/07/01/barcode-reader-demo

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Germany Germany
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
QuestionITC Pin
JOHN RICHARD QUITANEG20-Apr-17 15:36
JOHN RICHARD QUITANEG20-Apr-17 15:36 
QuestionTried it. worked. Pin
enterprisetoday7-Jul-14 15:27
professionalenterprisetoday7-Jul-14 15:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.