Moe DeShong
asked on
Trap all key strokes
If my form is not in edit mode I want to cancel all keystrokes. How do I do that?
Thanks
Thanks
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Messa ge)
Try
Select Case m.Msg
Case WM_KEYDOWN
Exit Sub
Case WM_KEYUP
Exit Sub
End Select
MyBase.WndProc(m)
Catch ex As Exception
MsgBox(ex.Message)
End Try
MyBase.WndProc(m)
End Sub
Try
Select Case m.Msg
Case WM_KEYDOWN
Exit Sub
Case WM_KEYUP
Exit Sub
End Select
MyBase.WndProc(m)
Catch ex As Exception
MsgBox(ex.Message)
End Try
MyBase.WndProc(m)
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks. Worked perfect.
ASKER
Just for clarification if e = nothing or e.handled is used this line
MyBase.KeyPreview = True
needs added to the form load event.
MyBase.KeyPreview = True
needs added to the form load event.
ASKER