0

我正在为带有 C# compact framework 2.0(windows mobile 6.1)中的 2D 阅读器的 Intermec 手持设备 CK30 开发。

每次我使用条形码时,我的键盘都会停止工作。任何想法为什么?

这是代码。第一部分是配置条形码阅读器的类。第二部分是使用条形码阅读器填充文本框的表单。

使用条形码阅读器读取内容后,键盘停止工作......

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;
        }
    }        
}
4

1 回答 1

1

好的,我现在 relaized 您正在一个单独的类中使用 BarcodeReader。

请尝试以下标准示例(一个列表框和一个按钮):

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();
    }
}

如果可行(另请参阅 Intermec Datacollection 资源工具包附带的示例),我们可以检查,为什么您的构造不起作用。我假设您安装了最新的 DataCollection Resource Kit。

于 2013-03-22T16:21:26.530 回答