MessageBoxService not working correctly

Topics: CAB & Smart Client Software Factory
Jul 5, 2006 at 11:05 AM
originally posted by: sklett

Funny that such a simple service would be giving me trouble. It works in 99% of the cases I'm using it, but in one case, the call to MessageBoxService.Show() return right away, no message box is shown. I have tried passing just a simple string literal "Test" and it makes no difference.

If I make a call to Show() on a reg. MessageBox class, it works fine. I have stepped as far into the code as I can, but there are no exceptions or errors.

has anyone else experienced this? If so, did you find a solution?

Here is the code I'm using:
string.Format("Serial number \'{0}\' doesn't appear to be a valid serial number.", _serialNumber));

string.Format("Serial number \'{0}\' doesn't appear to be a valid serial number.", _serialNumber));

The basic MessageBox.Show() call works fine.
Jul 5, 2006 at 11:10 AM
originally posted by: sklett

OK, that was quick, I found the problem. I'm using a barcode scanner to enter a serial number which is then being verified and if invalid, the message box is shown.

Problem is, the barcode scanner also sends a carriage return/newline after a read. When using the service, it appears that the slight additional time to execute allows the carriage return to simulate pressing the "OK" button, but the regular one doesn't suffer from this.

I guess I could make my own MessageBox class and allow the focus to not be set to the OK button, that might work, but it's not pretty.

if anyone has any ideas for me, I would really appreciate them.
Jul 8, 2006 at 6:29 AM
originally posted by: JKraft4PIT

Can you capture the carriage return before you use it and remove it before showing the serial nubmer?"Bad serial Number " & _serialNumber.Replace(vbCrLf, "")
Jul 8, 2006 at 10:38 AM
originally posted by: sklett

That's a good suggestion. I'm entering the serial number into a masked text box, so I could catch the text changed event and try removing it there.
A barcode scanner basically just sends keyboard input (from what I understand) - so I might also be able to respond to a keyDown event and remove it even earlier.

I didn't think of this, I was thinking too hard about a "clever" solution and didn't back up and take a high level look, that for the suggestion!
Have a good weekend!