ProcessCmdKey Double Firing

  • Thread starter Thread starter Craig Bennett
  • Start date Start date
C

Craig Bennett

I have some code to capture command keys. When I type
into a text box, the code runs once. When I type into a
combobox, the code runs twice. Can anyone explain this
behaviour to me? Here is the code which is in my form:

Protected Overrides Function ProcessCmdKey(ByRef msg
As _
System.Windows.Forms.Message, ByVal keyData As
System.Windows.Forms.Keys) As _
Boolean

Const WM_KEYDOWN As Integer = &H100

Dim blnHandled As Boolean = False

If msg.Msg = WM_KEYDOWN Then
Label1.Text = keyData.ToString & ":" &
Label1.Text
End If
blnHandled = MyBase.ProcessCmdKey(msg, keyData)

Return blnHandled
End Function
 
You need to return true if u process the message
else the same as u done.
i.e
blnHandled = MyBase.ProcessCmdKey(msg, keyData)
Return blnHandled
 
Back
Top