PreFilterMessage quesiton

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!
 
G

Guest

ToInt32 is a method, not a property. It must be m.LParam.ToInt32() with
parens.

-Chris
 
V

vbmark

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?
 
D

Daniel Moth

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
 
V

vbmark

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top