WM that has to do with pressing the enter key and TAB key.
-
Hello ! In this list of windows Messages : http://www.pinvoke.net/default.aspx/Constants/WM.html[^] which is the message that has to do with pressing the Enter key and the TAB key? I try with WM_KEYDOWN , but it seems that the enter and the tab key are not handled. Thank you !
-
Hello ! In this list of windows Messages : http://www.pinvoke.net/default.aspx/Constants/WM.html[^] which is the message that has to do with pressing the Enter key and the TAB key? I try with WM_KEYDOWN , but it seems that the enter and the tab key are not handled. Thank you !
-
It's been a while since I did ought like this but the WM_CHAR message should contain the key that actually went "down" I think
-
Protected Overrides Sub WndProc(ByRef m As Message)
If m.Msg = WM_CHAR Then
Return
End If
MyBase.WndProc(m)
End Sub
End Classall the other keys are blocked , but if TAB or Enter key is pressed then MyBase.WNDProc(m) is executed.
This will capture all of the keys using the ProcessCmdKey override rather than WndProc
Protected Overrides Function ProcessCmdKey(ByRef msg As Message, ByVal keyData As Keys) As Boolean
Const WM_KEYDOWN As Integer = &H100If ((msg.Msg = WM\_KEYDOWN)) Then Select Case (keyData) Case Keys.Tab Me.Label1.Text = "Tab Key Captured" Case Keys.Enter Me.Label1.Text = "Enter Key Captured" Case Keys.Return Me.Label1.Text = "Return Key Captured" Case Else Me.Label1.Text = keyData.ToString End Select End If Return MyBase.ProcessCmdKey(msg, keyData) End Function
But I really don't understand your problem as this also works for me.
Protected Overrides Sub WndProc(ByRef m As Message)
Const WM_CHAR = &H102
If m.Msg = WM_CHAR Then
Return
End If
MyBase.WndProc(m)
End Sub -
This will capture all of the keys using the ProcessCmdKey override rather than WndProc
Protected Overrides Function ProcessCmdKey(ByRef msg As Message, ByVal keyData As Keys) As Boolean
Const WM_KEYDOWN As Integer = &H100If ((msg.Msg = WM\_KEYDOWN)) Then Select Case (keyData) Case Keys.Tab Me.Label1.Text = "Tab Key Captured" Case Keys.Enter Me.Label1.Text = "Enter Key Captured" Case Keys.Return Me.Label1.Text = "Return Key Captured" Case Else Me.Label1.Text = keyData.ToString End Select End If Return MyBase.ProcessCmdKey(msg, keyData) End Function
But I really don't understand your problem as this also works for me.
Protected Overrides Sub WndProc(ByRef m As Message)
Const WM_CHAR = &H102
If m.Msg = WM_CHAR Then
Return
End If
MyBase.WndProc(m)
End SubThank you ! The problem with my code is that all other keys are blocked for the control , except the TAB key and Enter key. If you have test my code , you should see that for the control , all the other keys are blocked inside the IF . But for Tab key and Enter key , the IF condition is always false , and the standart WNDProc is executed.
-
This will capture all of the keys using the ProcessCmdKey override rather than WndProc
Protected Overrides Function ProcessCmdKey(ByRef msg As Message, ByVal keyData As Keys) As Boolean
Const WM_KEYDOWN As Integer = &H100If ((msg.Msg = WM\_KEYDOWN)) Then Select Case (keyData) Case Keys.Tab Me.Label1.Text = "Tab Key Captured" Case Keys.Enter Me.Label1.Text = "Enter Key Captured" Case Keys.Return Me.Label1.Text = "Return Key Captured" Case Else Me.Label1.Text = keyData.ToString End Select End If Return MyBase.ProcessCmdKey(msg, keyData) End Function
But I really don't understand your problem as this also works for me.
Protected Overrides Sub WndProc(ByRef m As Message)
Const WM_CHAR = &H102
If m.Msg = WM_CHAR Then
Return
End If
MyBase.WndProc(m)
End Subsorry but I can't use your function ProcessCMD. The reason is that I'm usng NativeWindow , and when I try to use your function , I get an error 'ProcessCmdKey' is not a member of 'System.Windows.Forms.NativeWindow'. What can I do ? This is my whole class that actually I'm using :
Class NW
Inherits NativeWindow
Public Sub New(hwnd As IntPtr)
AssignHandle(hwnd)
End Sub
Const WM_NCHITTEST As Integer = &H84
Const WM_CHAR As Integer = &H102
Protected Overrides Sub WndProc(ByRef m As Message)
If m.Msg = WM_NCHITTEST OrElse m.Msg = WM_CHAR Then
Return
End If
MyBase.WndProc(m)
End SubEnd Class
-
sorry but I can't use your function ProcessCMD. The reason is that I'm usng NativeWindow , and when I try to use your function , I get an error 'ProcessCmdKey' is not a member of 'System.Windows.Forms.NativeWindow'. What can I do ? This is my whole class that actually I'm using :
Class NW
Inherits NativeWindow
Public Sub New(hwnd As IntPtr)
AssignHandle(hwnd)
End Sub
Const WM_NCHITTEST As Integer = &H84
Const WM_CHAR As Integer = &H102
Protected Overrides Sub WndProc(ByRef m As Message)
If m.Msg = WM_NCHITTEST OrElse m.Msg = WM_CHAR Then
Return
End If
MyBase.WndProc(m)
End SubEnd Class
Sorry - I'm about to head off to the airport and won't get a chance to look at this properly. My advice is to post a question in Quick Answers forum - put in a link to this thread and include the code that you have posted here (you could also post the code I suggested and explain that it didn't work, so everything is in one place). Hopefully someone else will be able to pick it up while I'm away. P.S. - If anyone tells you off for cross-posting point them to this post and I'll take the flack :)