Making KeyDown event work for Cursor Keys with controls on your form
Private Const WM_KEYDOWN As Integer = 256
Private Const WM_KEYUP As Integer = 257
Public Function PreFilterMessage(ByRef m As System.Windows.Forms.Message) _
As Boolean Implements IMessageFilter.PreFilterMessage
If (m.Msg = WM_KEYDOWN) Then
Dim keyCode As Keys = (CType(CType(m.WParam, Integer), Keys) And Keys.KeyCode)
'do your stuff with the key down here
'.....
Return True
End If
Return False
End Function
Private Sub FrmPortFolio_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
Application.AddMessageFilter(Me)
End Sub
End Class
0 comments:
Post a Comment