Question

I`m developing for a Intermec handheld device CK30 with a 2D reader in C# compact framework 2.0 (windows mobile 6.1).

Everytime I use barcode mey keyboard stops working. Any ideas why?

Heres the code. The first section is a class that configures the barcode reader. The second section is a form that uses the barcode reader to fill a textbox.

After reading something with the barcode reader the keyboard stops working...

using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;

using Intermec.DataCollection;

namespace BarCodeReaderTest
{
    class LeitorCodigoDeBarras
    {
        public BarcodeReader LerCodigoDeBarras()
        {
            try
            {
                BarcodeReader meuLeitor = new BarcodeReader("default", 4096);
                meuLeitor.ScannerEnable = true;
                meuLeitor.ThreadedRead(true);

                return meuLeitor;
            }
            catch (BarcodeReaderException bx)
            {
                MessageBox.Show("Não foi possível inicializar o leitor de código de     barras. Contate seu supervisor. \n" + bx.Message);

                return null;
            }
        }
    }
}


using System;

using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

using Intermec.DataCollection;

namespace BarCodeReaderTest
{
    public partial class Form1 : Form
    {



        public BarcodeReader leitor;

        public Form1()
        {

            InitializeComponent();

            LeitorCodigoDeBarras classeLeitor = new LeitorCodigoDeBarras();

            leitor = classeLeitor.LerCodigoDeBarras();
            leitor.BarcodeRead += new     BarcodeReadEventHandler(this.eventoLeitorCodigoDeBarras);

        }


        void eventoLeitorCodigoDeBarras(object sender, BarcodeReadEventArgs e)
        {
            tbCodLido.Text = e.strDataBuffer;
        }
    }        
}
Was it helpful?

Solution

OK, I now relaized that you are using the BarcodeReader within a separate class.

Please try the follwing, standard, example (one listbox and one button in form):

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Intermec.DataCollection;
namespace BarcodeReader
{
    public partial class Form1 : Form
    {
        private Intermec.DataCollection.BarcodeReader bcr;
        public Form1()
        {
            InitializeComponent();
            bcr = new Intermec.DataCollection.BarcodeReader();
            bcr.BarcodeRead += new BarcodeReadEventHandler(bcr_BarcodeRead);
            bcr.ThreadedRead(true);
        }
        void bcr_BarcodeRead(object sender, BarcodeReadEventArgs bre)
        {
            this.listBox1.Items.Add(bre.strDataBuffer);
        }
    }
    private void btnExit_Click(object sender, EventArgs e)
    {
        if (bcr !=null)
        {
            bcr.Dispose();
        }
        Application.Exit();
    }
}

If that works (see also the examples coming with the Intermec Datacollection resource kit), we can examine, why you construct does not work. I assume you have the latest DataCollection Resource Kit installed.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top