PC Review


Reply
Thread Tools Rate Thread

OpenNetCF PreMessageFilter problem with VB.net

 
 
Enrico Pavesi
Guest
Posts: n/a
 
      17th Mar 2005
I create a class like this
Public Class KeyFilter
Implements IMessageFilter
Overridable Function PreFilterMessage(ByRef m As
Microsoft.WindowsCE.Forms.Message) As Boolean Implements
IMessageFilter.PreFilterMessage
Dim tasto As Integer

Select Case m.Msg
Case 786
tasto = m.WParam.ToInt32()
Select Case (tasto)
Case 193 To 196
Return True
End Select
End Select
Return False
End Function

End Class

then in the main form
InitializeComponent()
Dim Filtro As KeyFilter = New KeyFilter
ApplicationEx.AddMessageFilter(Filtro)

But this code does not trap the virtual hardware key

The same in a test C# project works.

Do someone knows why it does not work?

Thanks


 
Reply With Quote
 
 
 
 
Daniel Moth
Guest
Posts: n/a
 
      17th Mar 2005
Haven't looked at your code but read your question at the end. It sounds
like you have some code in C# that works and a VB version that doesn't. If
you post *both* versions we might be able to help.

Cheers
Daniel
--
http://www.danielmoth.com/Blog/


"Enrico Pavesi" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
>I create a class like this
> Public Class KeyFilter
> Implements IMessageFilter
> Overridable Function PreFilterMessage(ByRef m As
> Microsoft.WindowsCE.Forms.Message) As Boolean Implements
> IMessageFilter.PreFilterMessage
> Dim tasto As Integer
>
> Select Case m.Msg
> Case 786
> tasto = m.WParam.ToInt32()
> Select Case (tasto)
> Case 193 To 196
> Return True
> End Select
> End Select
> Return False
> End Function
>
> End Class
>
> then in the main form
> InitializeComponent()
> Dim Filtro As KeyFilter = New KeyFilter
> ApplicationEx.AddMessageFilter(Filtro)
>
> But this code does not trap the virtual hardware key
>
> The same in a test C# project works.
>
> Do someone knows why it does not work?
>
> Thanks
>


 
Reply With Quote
 
Enrico Pavesi
Guest
Posts: n/a
 
      21st Mar 2005
The C# version is:
class KeyFilter : IMessageFilter
{
public bool PreFilterMessage(ref Message m)
{
switch(m.Msg)
{
case 0x0312:
int tasto = m.WParam.ToInt32();
switch(tasto )
{
case 193:
case 196:
return true;
break;
}

break;
}
}
return false;
}
}

and after initialize component:
KeyFilter Filtro = new KeyFilter();
ApplicationEx.AddMessageFilter(Filtro);

In the VB version it never stop at message 786 (0x0312)

Thanks


"Daniel Moth" <(E-Mail Removed)> ha scritto nel messaggio
news:(E-Mail Removed)...
> Haven't looked at your code but read your question at the end. It sounds
> like you have some code in C# that works and a VB version that doesn't. If
> you post *both* versions we might be able to help.
>
> Cheers
> Daniel
> --
> http://www.danielmoth.com/Blog/
>
>
> "Enrico Pavesi" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
>>I create a class like this
>> Public Class KeyFilter
>> Implements IMessageFilter
>> Overridable Function PreFilterMessage(ByRef m As
>> Microsoft.WindowsCE.Forms.Message) As Boolean Implements
>> IMessageFilter.PreFilterMessage
>> Dim tasto As Integer
>>
>> Select Case m.Msg
>> Case 786
>> tasto = m.WParam.ToInt32()
>> Select Case (tasto)
>> Case 193 To 196
>> Return True
>> End Select
>> End Select
>> Return False
>> End Function
>>
>> End Class
>>
>> then in the main form
>> InitializeComponent()
>> Dim Filtro As KeyFilter = New KeyFilter
>> ApplicationEx.AddMessageFilter(Filtro)
>>
>> But this code does not trap the virtual hardware key
>>
>> The same in a test C# project works.
>>
>> Do someone knows why it does not work?
>>
>> Thanks
>>

>



 
Reply With Quote
 
Daniel Moth
Guest
Posts: n/a
 
      21st Mar 2005
Reading this in outlook I can't see anything obvious. I presume you are
using ApplicationEx etc from a C# library and not translated them to VB,
right? If you send the project with repro steps I can have a look at it.

A couple of general comments if you want them:
1. You don't have to translate the hex to int in VB. Just use &H0312
2. Not sure why you made the interface implementation Overridable. I would
replace that with Public.
3. Case 193 To 196. Replace To with ,

Cheers
Daniel
--
http://www.danielmoth.com/Blog/


"Enrico Pavesi" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> The C# version is:
> class KeyFilter : IMessageFilter
> {
> public bool PreFilterMessage(ref Message m)
> {
> switch(m.Msg)
> {
> case 0x0312:
> int tasto = m.WParam.ToInt32();
> switch(tasto )
> {
> case 193:
> case 196:
> return true;
> break;
> }
>
> break;
> }
> }
> return false;
> }
> }
>
> and after initialize component:
> KeyFilter Filtro = new KeyFilter();
> ApplicationEx.AddMessageFilter(Filtro);
>
> In the VB version it never stop at message 786 (0x0312)
>
> Thanks
>
>
> "Daniel Moth" <(E-Mail Removed)> ha scritto nel messaggio
> news:(E-Mail Removed)...
>> Haven't looked at your code but read your question at the end. It sounds
>> like you have some code in C# that works and a VB version that doesn't.
>> If you post *both* versions we might be able to help.
>>
>> Cheers
>> Daniel
>> --
>> http://www.danielmoth.com/Blog/
>>
>>
>> "Enrico Pavesi" <(E-Mail Removed)> wrote in message
>> news:%(E-Mail Removed)...
>>>I create a class like this
>>> Public Class KeyFilter
>>> Implements IMessageFilter
>>> Overridable Function PreFilterMessage(ByRef m As
>>> Microsoft.WindowsCE.Forms.Message) As Boolean Implements
>>> IMessageFilter.PreFilterMessage
>>> Dim tasto As Integer
>>>
>>> Select Case m.Msg
>>> Case 786
>>> tasto = m.WParam.ToInt32()
>>> Select Case (tasto)
>>> Case 193 To 196
>>> Return True
>>> End Select
>>> End Select
>>> Return False
>>> End Function
>>>
>>> End Class
>>>
>>> then in the main form
>>> InitializeComponent()
>>> Dim Filtro As KeyFilter = New KeyFilter
>>> ApplicationEx.AddMessageFilter(Filtro)
>>>
>>> But this code does not trap the virtual hardware key
>>>
>>> The same in a test C# project works.
>>>
>>> Do someone knows why it does not work?
>>>
>>> Thanks
>>>

>>

>
>


 
Reply With Quote
 
Enrico Pavesi
Guest
Posts: n/a
 
      22nd Mar 2005
The problem is that is an existing project and i can't send it.

If you have time you can post a 10 lines working vb project that trap
virtual hardkey.

In any case thanks for your hints

Regards



"Daniel Moth" <(E-Mail Removed)> ha scritto nel messaggio
news:(E-Mail Removed)...
> Reading this in outlook I can't see anything obvious. I presume you are
> using ApplicationEx etc from a C# library and not translated them to VB,
> right? If you send the project with repro steps I can have a look at it.
>
> A couple of general comments if you want them:
> 1. You don't have to translate the hex to int in VB. Just use &H0312
> 2. Not sure why you made the interface implementation Overridable. I would
> replace that with Public.
> 3. Case 193 To 196. Replace To with ,
>
> Cheers
> Daniel
> --
> http://www.danielmoth.com/Blog/
>
>
> "Enrico Pavesi" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> The C# version is:
>> class KeyFilter : IMessageFilter
>> {
>> public bool PreFilterMessage(ref Message m)
>> {
>> switch(m.Msg)
>> {
>> case 0x0312:
>> int tasto = m.WParam.ToInt32();
>> switch(tasto )
>> {
>> case 193:
>> case 196:
>> return true;
>> break;
>> }
>>
>> break;
>> }
>> }
>> return false;
>> }
>> }
>>
>> and after initialize component:
>> KeyFilter Filtro = new KeyFilter();
>> ApplicationEx.AddMessageFilter(Filtro);
>>
>> In the VB version it never stop at message 786 (0x0312)
>>
>> Thanks
>>
>>
>> "Daniel Moth" <(E-Mail Removed)> ha scritto nel messaggio
>> news:(E-Mail Removed)...
>>> Haven't looked at your code but read your question at the end. It sounds
>>> like you have some code in C# that works and a VB version that doesn't.
>>> If you post *both* versions we might be able to help.
>>>
>>> Cheers
>>> Daniel
>>> --
>>> http://www.danielmoth.com/Blog/
>>>
>>>
>>> "Enrico Pavesi" <(E-Mail Removed)> wrote in message
>>> news:%(E-Mail Removed)...
>>>>I create a class like this
>>>> Public Class KeyFilter
>>>> Implements IMessageFilter
>>>> Overridable Function PreFilterMessage(ByRef m As
>>>> Microsoft.WindowsCE.Forms.Message) As Boolean Implements
>>>> IMessageFilter.PreFilterMessage
>>>> Dim tasto As Integer
>>>>
>>>> Select Case m.Msg
>>>> Case 786
>>>> tasto = m.WParam.ToInt32()
>>>> Select Case (tasto)
>>>> Case 193 To 196
>>>> Return True
>>>> End Select
>>>> End Select
>>>> Return False
>>>> End Function
>>>>
>>>> End Class
>>>>
>>>> then in the main form
>>>> InitializeComponent()
>>>> Dim Filtro As KeyFilter = New KeyFilter
>>>> ApplicationEx.AddMessageFilter(Filtro)
>>>>
>>>> But this code does not trap the virtual hardware key
>>>>
>>>> The same in a test C# project works.
>>>>
>>>> Do someone knows why it does not work?
>>>>
>>>> Thanks
>>>>
>>>

>>
>>

>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Another PreMessageFilter problem! tclancey Microsoft VB .NET 1 22nd Mar 2007 06:59 PM
OpenNETCF 2.0 problem samynonsense Microsoft Dot NET Compact Framework 3 18th Aug 2006 07:13 AM
Compile OpenNetCF - OpenNETCF.Windows.Forms Vitaly Sedov Microsoft Dot NET Compact Framework 5 22nd Mar 2005 06:59 PM
OpenNETCF problem glenn Microsoft Dot NET Compact Framework 6 16th Feb 2005 09:59 PM
OpenNetCF.org has released v1.5 of the OpenNETCF.Desktop.Communication Chris Tacke, eMVP Microsoft Dot NET Compact Framework 1 30th Sep 2003 07:06 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:23 PM.