"Rob" <rl*****@worldn et.att.net> wrote in
news:OP******** ******@TK2MSFTN GP10.phx.gbl:
If I use the following code:
Private Sub Form1_KeyDown(B yVal sender As Object, _
ByVal e As System.Windows. Forms.KeyEventA rgs) _
Handles MyBase.KeyDown
Dim myKey As Integer
myKey = e.KeyValue
MsgBox(myKey.To String)
End Sub
all of my keyboard input is displayed in the MsgBox,
However if I use any of the arrow keys the KeyDown
event handler no longer works ! All keyboard input is
no longer displayed in the MsgBox and the handler no
longer works. How can I rewrite the code to handle
arrow key input. Using Microsoft Development
Environment 2002 Version 7.0.9955
With controls, you can get them to respond to the navigation keys by
deriving your own class and overriding IsInputKey:
Public Class Class1
Inherits Button
Protected Overrides Function IsInputKey(ByVa l keyData As
System.Windows. Forms.Keys) As Boolean
If keyData = Keys.Right Then Return True
Return MyBase.IsInputK ey(keyData)
End Function
End Class
Now, if you use a class1, it will trap the right arrow key in the keydown
event. However it won't move focus on to the next control anymore.
You can try this with a derived form, but it wont work. I'd guess that it
would break the navigation keys for all the controls on the form.
You could still trap it in a form by overriding wndproc :
Public Event RightArrowAlarm As EventHandler
Private Const VK_RIGHT = &H27
Private Const WM_KEYDOWN As Integer = &H100
Protected Overrides Sub WndProc(ByRef m As
System.Windows. Forms.Message)
If m.Msg = WM_KEYDOWN Then
If m.WParam = VK_RIGHT Then
RaiseEvent RightArrowAlarm (Me, New EventArgs)
End If
End If
MyBase.WndProc( m)
End Sub