Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / All-Topics

Barcode Reader Demo

3.67/5 (2 votes)
4 Jan 2010CPOL 22.4K  
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 -->

License

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