Now I have gone to the other extreem where "Private Sub Form_KeyDown"
never gets called:
To get the HWnd I do this:
Private Declare Function GetCapture Lib "CoreDll.dll" () As IntPtr
Public Sub New(ByVal DelegateFunction As MyKeyDownDelegate)
myfunc = DelegateFunction
Me.Capture = True
HWnd = GetCapture()
Me.Capture = False
End Sub
Then to compare:
Public Function PreFilterMessage(ByRef m As
Microsoft.WindowsCE.Forms.Message) As Boolean Implements
OpenNETCF.Windows.Forms.IMessageFilter.PreFilterMessage
If m.HWnd.Equals(HWnd) Then
Select Case m.Msg
Case Window.Messages.WM_KEYDOWN
myfunc.Invoke(New KeyEventArgs(m.WParam.ToInt32), _
m.LParam.ToInt32)
End Select
End If
End Function
But m.HWnd.Equals(HWnd) is NEVER true.
How do I fix?
Thanks!
Have you seen this [1] example? You must detect for which window
WM_KEYDOWN was sent:
Public Function PreFilterMessage(ByRef m As _
Microsoft.WindowsCE.Forms.Message) As Boolean _
Implements
OpenNETCF.Windows.Forms.IMessageFilter.PreFilterMessage
If m.HWnd = textBoxHwnd Then
...
End If
End Function
[1]
http://www.sergeybogdanov.com/Samples/TextBoxKeyDownFilter.zip
Best regards,
Sergey Bogdanov
http://www.sergeybogdanov.com
Here is my code:
http://code-7sd7gs7d.notlong.com
The events are triggering fine now but the problem is that it looks
as though "Private Sub Form_KeyDown" event is getting called for
every control in the array.
I'm adding the MessageFilter like this:
ApplicationEx.AddMessageFilter(m_oTextBox(x))
What's going on?
Thanks!