Click here to Skip to main content
15,887,391 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have a application which runs on WT41N0. This application has a form which accepts the label scanned by the scanner in a textbox on keyDown event.

C#
private void txtBarCode_KeyDown(object sender, KeyEventArgs e)
{
    if (e.KeyCode == Keys.Enter || e.KeyCode == Keys.Return)
    {
        string lstrBarCodeID = txtBarCode.Text.Trim();
    }
}


The problem is when I have a messagebox on the screen waiting for user input (Yes/No) and someone scans a barcode, the application takes action on the messagebox.

I want the application not to scan or scan but don't let the message box go disappear as a result. When user is using the application without looking at the screen, they keep on scanning without realizing that there is a message on the screen and keep scanning leading to issues with the operations. I just want to stop the application to perform any action until the user takes a action on the message on the screen.

I might be missing a trick as I am new to front-end programming with C#.

Thanks!

What I have tried:

I tried a few things like:

1. Disable the text box that takes the barcode scanned and enable when the user has selected Yes or No.

C#
txtBarCode.Enabled = false;


2. Used Symbol libraries and disable the scanner. (Even though I am not allowed to use these, so I have to find a solution without Symbol library)

C#
private Symbol.Barcode.Reader myReader = null;
myReader = new Symbol.Barcode.Reader();


Then disable the scanner when the messagebox is displayed:
C#
myReader.Actions.Disable();


Both these did not work. I do not want to use Symbol library though as this is not allowed in my organization.

Update:
I found that the barcode scanner has a 'carriage return' set at the end, which is being held in the input stream and 'fired' when I open a message box leading to the closure of MessageBox. Now, the question is how do I overcome this situation. When there is a message box or any Error being displayed on the screen the user should be forced to acknowledge the error message/message box first.
Posted
Updated 6-May-18 11:55am
v2

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900