0

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.

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. This happens because the barcode scanner has a 'ENTER' (carriage return) symbol 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.

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#.

VkG
  • 1
  • 2
  • There are several options. As a workaround, you may replace the MessageBox by a custom form with buttons that do not accept keystrokes (unassigned AcceptButton and CancelButton properties), only mouse clicks. You may also add a keyboard hook and process the messages accordingly, depending on the app status, i.e. MessageBox opened or not. – KBO May 08 '18 at 06:06
  • for some tricky workaround read @Sriram Sakthivel answer on this [link](https://stackoverflow.com/questions/28624271/messagebox-without-focus-on-a-messageboxbutton?rq=1) – Baskar John May 08 '18 at 06:35

0 Answers0