Randy
Thanks, that definitely was a step in the right direction. I put in both
the IsInputKey and IsInputChar routines (included below) and I now get the
RS character in the final output. I still don't get the GS and EOT
characters, though, even though they are handled in the IsInputChar routine
(I see the debug printouts). I suspect that this is due to a problem with
how I am handling them in the IsInputKey routine. Do you have any other
suggestions?
Thanks again,
Ron L
'********************* ControlCharactersTextBox Class
********************************
Imports System.Windows.Forms
Public Class CtlCharTextBox
Inherits System.Windows.Forms.TextBox
Protected Overrides Function IsInputKey(ByVal keyData As
System.Windows.Forms.Keys) As Boolean
If (keyData And Keys.Control) And (keyData And Keys.D) Then
Debug.WriteLine("IsInputKey: <EOT>")
Return True
ElseIf (keyData And Keys.Control) And (keyData And
Keys.OemCloseBrackets) Then
Debug.WriteLine("IsInputKey: <GS>")
Return True
ElseIf (keyData And Keys.Control) And (keyData And Keys.D6) Then
Debug.WriteLine("IsInputKey: <RS>")
Return True
Else
Return MyBase.IsInputKey(keyData)
End If
End Function
Protected Overrides Function IsInputChar(ByVal charCode As Char) As
Boolean
'Return MyBase.IsInputChar(charCode)
Select Case Asc(charCode)
Case 4 ' EOT character
'Debug.Write(Asc(charCode) & ", " & "<EOT> ")
Return True
Case 29 ' GS character
'Debug.Write(Asc(charCode) & ", " & "<GS> ")
Return True
Case 30 ' RS character
'Debug.Write(Asc(charCode) & ", " & "<RS> ")
Return True
Case Else
'Debug.Write(Asc(charCode) & ", " & charCode & " ")
Return MyBase.IsInputChar(charCode)
End Select
End Function
End Class
Hello, Ron,
Perhaps these keys are being swallowed by some preprocessing on the form.
Have a look at the help for the "IsInputKey" (and possibly the
"IsInputChar") function. Perhaps they will help you out. I have
previously used the former in order to "capture" some of the navigation
keys. Here is an example of IsInputKey:
Protected Overrides _
Function IsInputKey(ByVal keyData As Keys) As Boolean
' Inhibit pre-processing for selected "special" keys
' that are handled directly by the control.
Select Case keyData
Case Keys.Down, Keys.Left, Keys.Right, Keys.Up
Return (Me.UserMode = aenmUserMode.Design)
Case Else
Return False
End Select
End Function
Cheers,
Randy
Ron L wrote:
Randy
Sorry, I should have been more specific. The text box removes *some* of
the control characters. My string has the RS (ASCII 30), GS (ASCII 29),
and EOT (ASCII 4) embedded in it. These are commonly represented as
ctl-^, ctl-], and ctl-D, respectively. If I open a command prompt and
scan the label I see all the expected control characters on the entered
line, but in the text box the GS and EOT have been stripped out! Given
that, I am reasonably that either the TextBox or some portion of the
windows key event handling is removing the GS and EOT characters from my
input string.
Arrggghhhh!
Ron L
Hello, Ron,
I'm not aware of any logic that strips out control characters from a
TextBox. For example, when I type into a multiline textBox using a
keyboard I can easily insert new line characters (<CR><LF>) by typing
<CNTL><Enter>, or other control characters by using Copy/Paste. These
are returned in the Text property.
Also, almost all keystrokes (including the Control keys) are available
via the Key-up events. (As I recall there are a few "navigation" keys
that do not normally appear there, but I think that even these can be
persuaded to appear with a little extra work.)
I wonder if there is something between the scanner driver and the TextBox
that is swallowing the characters you are expecting to see. Do you have
KeyPreview enabled for the Form that contains the TextBox? Or is there
possibly something more sophisticated such as an override of WndProc
interfering?
Anyway, I'm rather doubtful that the problem is with the TextBox.
Cheers,
Randy
Ron L wrote:
Randy
I am using a text box control, but apparently there is logic in that
control that strips out most of the control characters (ASCII values <
32) before entering them into the Text property. I had hoped that by
catching the Key-up event I could somehow "bypass" the code that removes
the control characters.
As far as the scanner is concerned, it is simply acting as if it is a
keyboard and is sending on the characters that were "typed".
Thanks,
Ron L
Hello, Ron,
I've never worked with a scanner, so please excuse my ignorance. What
kind of control is it that receives the input? (I had assumed it would
be something akin to a TextBox and you could just use the Text property
after completion of the input.)
But when you say that you're catching the key-up event, perhaps the
processing required is more sophisticated than I realized.
Can you provide any additional information, or perhaps an example of
the code that you are trying to make work?
Cheers,
Randy
Ron L wrote:
Randy
Thanks for the response. My problem is that the scanner acts like a
keyboard, so I'm not sure how to get the original informaion into a
string in the first place. I have tried catching the key up event,
but I haven't figured out what to place in the string to get the
control characters into the string. I have printed out the key
values, and can't find a correlation between the key value or key code
and the control character I am expecting to see.
Ron L