Input Device Problems

  • Thread starter Thread starter jp2msft
  • Start date Start date
J

jp2msft

I've got an application that takes input from a handheld scanner: Once the
incoming text meets the RegEx format and is the correct length, the command
is accepted.

The scanner that plugs in on the keyboard port.

The problem comes from the use of the default MessageBox whenever I need to
display information to the operator:

DialogResult dr =
MessageBox.Show("Do this?", Title,
MessageBoxButtons.YesNo,
MessageBoxIcon.Question,
DefaultButton.Button1);

Sometimes, these scanners send in more data (usually blank spaces) after a
MessageBox is displayed, and (as some of you may know) the space bar can be
used to select the default button.

I would like to flush the scanner's buffer, effectively flushing the
keyboard buffer? Are p/invoke calls needed for this, or is there something in
the Framework?

I'm running 2.0 Framework with Visual Studio 2005 - but I'll take tips and
how-to info from just about anything.

Thanks,
~Joe
 
Hi Pete,

Thanks for the fast response!

Yes: There is a form that is waiting on input. The problem is complicated by
the fact that both a scanner and the keyboard are allowed - just in case an
item is too dirty to be scanned, a scanner gets dropped/smashed, or any other
unforeseeable (sp?) mishap.

The keyboard requirement prevents implimenting a timer, and processing
starts once the RegEx expression is met.

Creating a custom modal form is a good idea. I did think of this myself, but
dismissed it, thinking that this was a more complicated solution than
learning how to use tools that were at my disposal.

Along that same line, now I am thinking about shifting the Focus to a
ReadOnly textbox as soon as the RegEx expression is met. This should allow
all of the remaining buffer characters to be consumed without anything in my
application trying to use them. It still sounds like a hack, though. :)
 
Sometimes my head can be hard, and it is difficult to get a new idea or two
in there. But, this time I did it! ;)

I've got a timer checking the input. As it turned out, there was already a
timer on the form ticking every 200 ms, so I just added a text input checker
to that routine.

Thanks for being patient with an old, hard headed donkey!
 
Back
Top