使用 C# 按下 Datalogic 存储设备上的扫描按钮时的替代事件

发布于 2024-12-29 11:05:49 字数 131 浏览 4 评论 0原文

我正在使用 C# 2003 作为 Datalogic Memor 应用程序。我研究过,按下设备的“扫描按钮”时会触发 KeyPress 事件。捕获它是 if(e.KeyChar == 13) 但它不起作用。还有其他选择吗?

I'm using C# 2003 for a Datalogic Memor application. I have researched that a KeyPress Event is triggered when the "scan button" of the device is pressed. Capturing it was if(e.KeyChar == 13) but it doesn't work. Is there another alternative for this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

作死小能手 2025-01-05 11:05:49

尝试安装 Datalogic SDK 2_0_0_0
您可以从 Datalogic得利捷 网站。

然后添加对 datalogic API 的引用:

C:\Program Files\Microsoft.NET\SDK\CompactFramework\v3.5\WindowsCE\Datalogic.API.dll

现在您可以通过以下方式使用 API:

在您的表单声明上: 在

private DecodeEvent dcdEvent;
private DecodeHandle hDcd;

您的表单加载事件上:

// Attempt to load a handle to the decoder.

try
{
    hDcd = new DecodeHandle(DecodeDeviceCap.Exists | DecodeDeviceCap.Barcode);
}
catch(DecodeException)
{
    MessageBox.Show("Exception loading barcode decoder.", "Decoder Error");
    return;
}

// Now that we've got a connection to a barcode reading device, assign a
// method for the DcdEvent.  A recurring request is used so that we will
// continue to get barcode data until our dialog is closed.
DecodeRequest reqType = (DecodeRequest)1 | DecodeRequest.PostRecurring;

// Initialize all events possible
//dcdEvent = new DecodeEvent(hDcd, reqType);
dcdEvent = new DecodeEvent(hDcd, reqType, this);
dcdEvent.Scanned += new DecodeScanned(dcdEvent_Scanned);

这是您的事件侦听器:

private void dcdEvent_Scanned(object sender, DecodeEventArgs e)
{
    CodeId cID = CodeId.NoData;
    string dcdData = string.Empty;
    // Obtain the string and code id.
    try
    {
        dcdData = hDcd.ReadString(e.RequestID, ref cID);
    }
    catch(Exception)
    {
        MessageBox.Show("Error reading string!");
        return;
    }

    string result = "Barcode Text: " + dcdData;
    result +=" AND Barcode Code Id : " + cID.ToString();
    MessageBox.Show(result);
}

在您的表单关闭事件上:

if(dcdEvent.IsListening)
{
    dcdEvent.StopScanListener();
}

if (hDcd != null)
{
    hDcd.Dispose();
} 

Try to install Datalogic SDK 2_0_0_0
You can Download it from Datalogic website.

And then add a reference to the datalogic API :

C:\Program Files\Microsoft.NET\SDK\CompactFramework\v3.5\WindowsCE\Datalogic.API.dll

Now you can Use the API in this way:

On your Form declaration:

private DecodeEvent dcdEvent;
private DecodeHandle hDcd;

On your form loading event:

// Attempt to load a handle to the decoder.

try
{
    hDcd = new DecodeHandle(DecodeDeviceCap.Exists | DecodeDeviceCap.Barcode);
}
catch(DecodeException)
{
    MessageBox.Show("Exception loading barcode decoder.", "Decoder Error");
    return;
}

// Now that we've got a connection to a barcode reading device, assign a
// method for the DcdEvent.  A recurring request is used so that we will
// continue to get barcode data until our dialog is closed.
DecodeRequest reqType = (DecodeRequest)1 | DecodeRequest.PostRecurring;

// Initialize all events possible
//dcdEvent = new DecodeEvent(hDcd, reqType);
dcdEvent = new DecodeEvent(hDcd, reqType, this);
dcdEvent.Scanned += new DecodeScanned(dcdEvent_Scanned);

And this is your event listener:

private void dcdEvent_Scanned(object sender, DecodeEventArgs e)
{
    CodeId cID = CodeId.NoData;
    string dcdData = string.Empty;
    // Obtain the string and code id.
    try
    {
        dcdData = hDcd.ReadString(e.RequestID, ref cID);
    }
    catch(Exception)
    {
        MessageBox.Show("Error reading string!");
        return;
    }

    string result = "Barcode Text: " + dcdData;
    result +=" AND Barcode Code Id : " + cID.ToString();
    MessageBox.Show(result);
}

ON your form closing event:

if(dcdEvent.IsListening)
{
    dcdEvent.StopScanListener();
}

if (hDcd != null)
{
    hDcd.Dispose();
} 
乙白 2025-01-05 11:05:49

对于 Datalogic Memor X3,我像这样使用 DLScannerListener:

DLScanner Scanner = new DLScanner();
Scanner.init();
Scanner.scanEnable();
Scanner.Listeners += new DLScannerListener(scanner_notify);

然后我在方法 scanner_notify 中执行逻辑

private void scanner_notify(DLScannerEvent scannerEvent, DLScanner sender)
{
    //Write your code here
}

For the Datalogic Memor X3 I use the DLScannerListener like this:

DLScanner Scanner = new DLScanner();
Scanner.init();
Scanner.scanEnable();
Scanner.Listeners += new DLScannerListener(scanner_notify);

Then I do the logic inside the method scanner_notify

private void scanner_notify(DLScannerEvent scannerEvent, DLScanner sender)
{
    //Write your code here
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文