PreFilterMessage quesiton

  • Thread starter Thread starter vbmark
  • Start date Start date
V

vbmark

Here is the PreFilterMessage function:

Public Function PreFilterMessage(ByRef m As _
Microsoft.WindowsCE.Forms.Message) As Boolean Implements _
OpenNETCF.Windows.Forms.IMessageFilter.PreFilterMessage
If m.HWnd.Equals(pHWnd) Then
Select Case m.Msg
Case Window.Messages.WM_KEYDOWN
'myKPfunc.Invoke(New KeyPressEventArgs(m.WParam.ToInt32), _
'm.LParam.ToInt32)
myKPfunc.Invoke(New KeyPressEventArgs(Chr(m.Msg)), _
m.LParam.ToInt32)
PreFilterMessage = True
End Select
End If
End Function

I keep getting an error on myKPfunc.

I think it's because I don't have the correct perameter for
KeyPressEventArgs.

Any ideas?

Thanks!
 
That didn't help.

The tooltip said to do this:

ChrW(m.WParam.ToInt32()

So the line now looks like this:

myKPfunc.Invoke(New KeyPressEventArgs(ChrW(m.WParam.ToInt32())),
m.LParam.ToInt32)

But I go this error.

An unhandled exception of type 'System.NullReferenceException' occurred
in MLA.exe

Any other ideas?
 
What is myKPfunc and is it not Nothing before you Invoke on it? Usually
Invoke methods take delegate instances (and for controls only of type
EventHandler). Post a small reproducible sample and we can help debug it for
you.

<offTopic>
Brackets/parenthesis after VB methods are never a problem. For backwards
compatibility it allows them not to be there which can result in confusing
to read code so you should add them as good practise. Unfortunately the
editor is too clever by half in places like paramterless constructors where
you add the () and it removes them.
</offTopic>

Cheers
Daniel
 
What is myKPfunc and is it not Nothing before you Invoke on it?
Usually Invoke methods take delegate instances (and for controls only
of type EventHandler). Post a small reproducible sample and we can
help debug it for you.

I've decided to do things differently so this is not needed now.
<offTopic>
Brackets/parenthesis after VB methods are never a problem. For
backwards compatibility it allows them not to be there which can
result in confusing to read code so you should add them as good
practise. Unfortunately the editor is too clever by half in places
like paramterless constructors where you add the () and it removes
them. </offTopic>

Tips are always welcomed. Thanks.
 
Back
Top