V
vbMark
Here is my class:
Public Class clsTextBox
Inherits TextBox
Implements OpenNETCF.Windows.Forms.IMessageFilter
Delegate Sub MyKeyDownDelegate(ByVal e As KeyEventArgs, _
ByVal lparam As Integer)
Private myfunc As MyKeyDownDelegate
Public Sub New(ByVal DelegateFunction As MyKeyDownDelegate)
myfunc = DelegateFunction
End Sub
Public Function PreFilterMessage(ByRef m As _
Microsoft.WindowsCE.Forms.Message) As Boolean _
Implements OpenNETCF.Windows.Forms.IMessageFilter.PreFilterMessage
Try
Select Case m.Msg 'Break point here!
Case Window.Messages.WM_KEYDOWN
myfunc.Invoke(New KeyEventArgs(m.WParam.ToInt32), _
m.LParam.ToInt32)
End Select
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Function
End Class
Here is the important stuff of my Main Form:
..
..
Private m_oTextBox() As clsTextBox
..
..
Private Sub Form_KeyDown(ByVal e As System.Windows.Forms.KeyEventArgs, _
ByVal lparam As Int32)
MsgBox("yo")
End Sub
..
..
m_oTextBox(x) = New clsTextBox(AddressOf Form_KeyDown)
..
..
ApplicationEx.AddMessageFilter(m_oTextBox(x))
..
etc.
The key down events are just not intercepted.
Putting a breakpoint in PreFilterMessage shows that code never goes
there.
I get no errors and everything works fine but not the intercept.
What am I missing or doing wrong?
Thanks!
Public Class clsTextBox
Inherits TextBox
Implements OpenNETCF.Windows.Forms.IMessageFilter
Delegate Sub MyKeyDownDelegate(ByVal e As KeyEventArgs, _
ByVal lparam As Integer)
Private myfunc As MyKeyDownDelegate
Public Sub New(ByVal DelegateFunction As MyKeyDownDelegate)
myfunc = DelegateFunction
End Sub
Public Function PreFilterMessage(ByRef m As _
Microsoft.WindowsCE.Forms.Message) As Boolean _
Implements OpenNETCF.Windows.Forms.IMessageFilter.PreFilterMessage
Try
Select Case m.Msg 'Break point here!
Case Window.Messages.WM_KEYDOWN
myfunc.Invoke(New KeyEventArgs(m.WParam.ToInt32), _
m.LParam.ToInt32)
End Select
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Function
End Class
Here is the important stuff of my Main Form:
..
..
Private m_oTextBox() As clsTextBox
..
..
Private Sub Form_KeyDown(ByVal e As System.Windows.Forms.KeyEventArgs, _
ByVal lparam As Int32)
MsgBox("yo")
End Sub
..
..
m_oTextBox(x) = New clsTextBox(AddressOf Form_KeyDown)
..
..
ApplicationEx.AddMessageFilter(m_oTextBox(x))
..
etc.
The key down events are just not intercepted.
Putting a breakpoint in PreFilterMessage shows that code never goes
there.
I get no errors and everything works fine but not the intercept.
What am I missing or doing wrong?
Thanks!