473,326 Members | 2,438 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

WM5 problem

Tym
Hi guys and gals!

Been trying to program following Maarten Struys' demos on the SMS
intereception and I'm having severe problems.

First of all, I'm a VBer not VC, though for this I have tried to work my way
through VC!!

I took the BASIC code from Marteen's example, and derived this:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.WindowsMobile;
using Microsoft.WindowsMobile.Status;
using Microsoft.WindowsMobile.PocketOutlook ;
using Microsoft.WindowsMobile.PocketOutlook.MessageInter ception;
namespace DeviceApplication1
{
public partial class Form1 : Form
{
private MessageInterceptor sms;
private SystemState networkConnectionState;
private SystemState cradleState;
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
sms = new
MessageInterceptor(InterceptionAction.NotifyAndDel ete);
sms.MessageCondition = new MessageCondition(MessageProperty.Body
, MessagePropertyComparisonType.StartsWith , "123456");
sms.MessageReceived += new
MessageInterceptorEventHandler(sms_MessageReceived );
}

void sms_MessageReceived(object sender, MessageInterceptorEventArgs
e)
{
Msgbox("SMS RECEIVED");
}
}
}
Now, the only it here that doesn't work is the Msgbox - why? what's the VC
equivalent??? (in compactframework - there's one in VB!)

That aside, converting this to VB gives:

Imports System
Imports System.Collections.Generic
Imports System.Drawing
Imports System.Text
Imports System.Windows.Forms
Imports Microsoft.WindowsMobile
Imports Microsoft.WindowsMobile.Status
Imports Microsoft.WindowsMobile.PocketOutlook
Imports Microsoft.WindowsMobile.PocketOutlook.MessageInter ception

Public partial Class Form1
Inherits Form
Private sms As MessageInterceptor
Private networkConnectionState As SystemState
Private cradleState As SystemState
Public Sub New()
InitializeComponent()
End Sub

Private Sub New_Load(ByVal sender As Object, ByVal e As EventArgs)
sms = New MessageInterceptor(InterceptionAction.NotifyAndDel ete)
sms.MessageCondition = New MessageCondition(MessageProperty.Body
, MessagePropertyComparisonType.StartsWith , "123456")
sms.MessageReceived += New
MessageInterceptorEventHandler(sms_MessageReceived )
End Sub

Private Sub sms_MessageReceived(ByVal sender As Object, ByVal e As
MessageInterceptorEventArgs)
Msgbox("SMS RECEIVED")
End Sub
End Class
'----------------------------------------------------------------
' Converted from C# to VB .NET using CSharpToVBConverter(1.2).
' Developed by: Kamal Patel (http://www.KamalPatel.net)
'----------------------------------------------------------------

[Credit left in obviously! Thanks Kamal!]

Now with this, the "sms.MessageReceived" is underlined blue, with the error
message:

'Public Event MessageReceived(sender As Object, e As
Microsoft.WindowsMobile.PocketOutlook.MessageInter ception.MessageInterceptorEventArgs)'
is an event, and cannot be called directly. Use a 'RaiseEvent' statement to
raise an event

I'm afraid that
http://msdn2.microsoft.com/en-us/lib...ed(vs.80).aspx doesn't
explain it enough for me and I still can't get it to work.
The "sms_MessageReceived" si also underlined blue with:
'Microsoft.WindowsMobile.PocketOutlook.MessageInte rception.MessageInterceptorEventHandler'
is a delegate type and requires a single 'addressof' expression as the only
argument to the constructor.

What gets me is that EXACTLY the same code is OK in VC but not VB. Also, the
intellisense in VC is supoerb - why does my VB environment not give
it??!?!?!
Tym

Apr 24 '07 #1
9 1082
Hi Tym,

"Tym" <sp******@ictis.netwrote in message
news:46**********************@ptn-nntp-reader02.plus.net...
Msgbox("SMS RECEIVED");
Now, the only it here that doesn't work is the Msgbox - why? what's the VC
equivalent??? (in compactframework - there's one in VB!)
Use MessageBox::Show
That aside, converting this to VB gives:
sms.MessageReceived += New
MessageInterceptorEventHandler(sms_MessageReceived )
End Sub

Private Sub sms_MessageReceived(ByVal sender As Object, ByVal e As
MessageInterceptorEventArgs)
Msgbox("SMS RECEIVED")
End Sub
End Class

Now with this, the "sms.MessageReceived" is underlined blue, with the
error message:
VB doesn't have a += for setting up events. Use AddHandler instead:

AddHandler sms.MessageReceived, AddressOf sms_MessageReceived

HTH,
SvenC

Apr 24 '07 #2
Tym
Many Thanks!
"SvenC" <Sv***@community.nospamwrote in message
news:09**********************************@microsof t.com...
Hi Tym,

"Tym" <sp******@ictis.netwrote in message
news:46**********************@ptn-nntp-reader02.plus.net...
> Msgbox("SMS RECEIVED");
Now, the only it here that doesn't work is the Msgbox - why? what's the
VC equivalent??? (in compactframework - there's one in VB!)

Use MessageBox::Show
>That aside, converting this to VB gives:
sms.MessageReceived += New
MessageInterceptorEventHandler(sms_MessageReceive d)
End Sub

Private Sub sms_MessageReceived(ByVal sender As Object, ByVal e
As MessageInterceptorEventArgs)
Msgbox("SMS RECEIVED")
End Sub
End Class

Now with this, the "sms.MessageReceived" is underlined blue, with the
error message:

VB doesn't have a += for setting up events. Use AddHandler instead:

AddHandler sms.MessageReceived, AddressOf sms_MessageReceived

HTH,
SvenC

Apr 24 '07 #3
Tym

"SvenC" <Sv***@community.nospamwrote in message
news:09**********************************@microsof t.com...
Hi Tym,
Use MessageBox::Show
The VC versin oworks fine! Thanks - however, I don't know VC at all really
and don't want to have to learn in to write my app!
>
AddHandler sms.MessageReceived, AddressOf sms_MessageReceived
The problem I have with this in VB is that the event is not triggered!! even
though it's the same code as VC

Any ideas?
Apr 24 '07 #4
Hi Tym,

"Tym" <sp******@ictis.netwrote in message
news:46**********************@ptn-nntp-reader02.plus.net...
>
"SvenC" <Sv***@community.nospamwrote in message
news:09**********************************@microsof t.com...
>>
AddHandler sms.MessageReceived, AddressOf sms_MessageReceived

The problem I have with this in VB is that the event is not triggered!!
even though it's the same code as VC

Any ideas?
Please read the documentation of WithEvents, maybe that does some extra
stuff to get the event wired up correctly.

--
SvenC

Apr 25 '07 #5
Tym
My VB knowledge isn't as technical as I'd like!

Read withevents, but still don't fully understand what's happenning.

"SvenC" <Sv***@community.nospamwrote in message
news:4C**********************************@microsof t.com...
Hi Tym,

"Tym" <sp******@ictis.netwrote in message
news:46**********************@ptn-nntp-reader02.plus.net...
>>
"SvenC" <Sv***@community.nospamwrote in message
news:09**********************************@microso ft.com...
>>>
AddHandler sms.MessageReceived, AddressOf sms_MessageReceived

The problem I have with this in VB is that the event is not triggered!!
even though it's the same code as VC

Any ideas?

Please read the documentation of WithEvents, maybe that does some extra
stuff to get the event wired up correctly.

--
SvenC

Apr 26 '07 #6
Hi Tym,
"SvenC" <Sv***@community.nospamwrote in message
news:4C**********************************@microsof t.com...
>>>>
AddHandler sms.MessageReceived, AddressOf sms_MessageReceived

The problem I have with this in VB is that the event is not triggered!!
even though it's the same code as VC

Any ideas?

Please read the documentation of WithEvents, maybe that does some extra
stuff to get the event wired up correctly.
My VB knowledge isn't as technical as I'd like!
Read withevents, but still don't fully understand what's happenning.
Please show us the VB code you have come up with now.

BTW, do you have a working demo of the SMS component? Can you verify that
the component is fireing its events and the problem is only with handling
the events not with raising them?

--
SvenC

Apr 26 '07 #7
Tym

"Please show us the VB code you have come up with now.
>
BTW, do you have a working demo of the SMS component? Can you verify that
the component is fireing its events and the problem is only with handling
the events not with raising them?
In VC# it works perfectly

VB Code:

Imports System

Imports System.Collections.Generic

Imports System.Drawing

Imports System.Text

Imports System.Windows.Forms

Imports Microsoft.WindowsMobile

Imports Microsoft.WindowsMobile.Status

Imports Microsoft.WindowsMobile.PocketOutlook

Imports Microsoft.WindowsMobile.PocketOutlook.MessageInter ception

Partial Public Class Form1

Inherits Form

Private sms As MessageInterceptor

Private networkConnectionState As SystemState

Private cradleState As SystemState

Private Event MessageReceived()

Public Sub New()

InitializeComponent()

End Sub

Private Sub New_Load(ByVal sender As Object, ByVal e As EventArgs)

sms = New MessageInterceptor(InterceptionAction.NotifyAndDel ete)

sms.MessageCondition = New MessageCondition(MessageProperty.Body,
MessagePropertyComparisonType.StartsWith, "123456")

AddHandler sms.MessageReceived, AddressOf sms_MessageReceived

RaiseEvent MessageReceived()

End Sub

Private Sub sms_MessageReceived(ByVal sender As Object, ByVal e As
MessageInterceptorEventArgs)

MsgBox("SMS RECEIVED")

End Sub

End Class
Apr 26 '07 #8
Hi Tym,

"Tym" <sp******@ictis.netwrote in message
news:46**********************@ptn-nntp-reader02.plus.net...
>
"Please show us the VB code you have come up with now.
>>
BTW, do you have a working demo of the SMS component? Can you verify that
the component is fireing its events and the problem is only with handling
the events not with raising them?
In VC# it works perfectly

VB Code:
Imports System
Imports System.Collections.Generic
Imports System.Drawing
Imports System.Text
Imports System.Windows.Forms
Imports Microsoft.WindowsMobile
Imports Microsoft.WindowsMobile.Status
Imports Microsoft.WindowsMobile.PocketOutlook
Imports Microsoft.WindowsMobile.PocketOutlook.MessageInter ception

Partial Public Class Form1

Inherits Form

Private sms As MessageInterceptor
Private networkConnectionState As SystemState
Private cradleState As SystemState
Private Event MessageReceived()
That line states that you want to raise an event not handle an event. Do you
want to use it to propagate the sms events to your caller? If not you can
delete that
Private Sub New_Load(ByVal sender As Object, ByVal e As EventArgs)

sms = New MessageInterceptor(InterceptionAction.NotifyAndDel ete)

sms.MessageCondition = New MessageCondition(MessageProperty.Body,
MessagePropertyComparisonType.StartsWith, "123456")

AddHandler sms.MessageReceived, AddressOf sms_MessageReceived
This should set up that sms_MessageReceived is called whenever you
MessageInterceptor class raises the MessageReceived event. Do you know if
the MessageInterceptor does fire events?
RaiseEvent MessageReceived()
That fires *your* event which can be caught by some code which added an
event handler for *your* event. That has no connection to the
MessageInterceptor's handler

Private Sub sms_MessageReceived(ByVal sender As Object, ByVal e As
MessageInterceptorEventArgs)

MsgBox("SMS RECEIVED")

End Sub
The above can only be raised from within the sms-Object.
Does that object maybe have some method to start/stop listening for
messages, so that you would need to call something like sms.Start,
sms.Enabled = true or alike? Please compare that carefully with the C# code.

--
SvenC

Apr 27 '07 #9
Tym
Hi SvenC,

Thanks for your time on this - it still wouldn't work, so I googled on
..messagecondition - found a great site and amended the code as follows:

Imports System

Imports System.Collections.Generic

Imports System.Drawing

Imports System.Text

Imports System.Windows.Forms

Imports Microsoft.WindowsMobile

Imports Microsoft.WindowsMobile.Status

Imports Microsoft.WindowsMobile.PocketOutlook

Imports Microsoft.WindowsMobile.PocketOutlook.MessageInter ception

Public Class Form1

Private sms As MessageInterceptor

Private networkConnectionState As SystemState

Private cradleState As SystemState

Public Sub New()

InitializeComponent()

End Sub

Private Sub sms_MessageReceived(ByVal sender As Object, ByVal e As
MessageInterceptorEventArgs)

MsgBox("SMS RECEIVED")

End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

sms = _

New MessageInterceptor( _

InterceptionAction. _

NotifyAndDelete, _

True)

'---set the filter for the

' message

sms. _

MessageCondition = _

New MessageCondition( _

MessageProperty.Body, _

MessagePropertyComparisonType. _

StartsWith, "invoke", True)

'---set the event handler for

' the message interceptor

AddHandler _

sms. _

MessageReceived, _

AddressOf _

sms_MessageReceived

End Sub

End Class

This now appears to work - thanks for your responses

Tym
Apr 28 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Kostatus | last post by:
I have a virtual function in a base class, which is then overwritten by a function of the same name in a publically derived class. When I call the function using a pointer to the derived class...
117
by: Peter Olcott | last post by:
www.halting-problem.com
18
by: Ian Stanley | last post by:
Hi, Continuing my strcat segmentation fault posting- I have a problem which occurs when appending two sting literals using strcat. I have tried to fix it by writing my own function that does the...
28
by: Jon Davis | last post by:
If I have a class with a virtual method, and a child class that overrides the virtual method, and then I create an instance of the child class AS A base class... BaseClass bc = new ChildClass();...
6
by: Ammar | last post by:
Dear All, I'm facing a small problem. I have a portal web site, that contains articles, for each article, the end user can send a comment about the article. The problem is: I the comment length...
16
by: Dany | last post by:
Our web service was working fine until we installed .net Framework 1.1 service pack 1. Uninstalling SP1 is not an option because our largest customer says service packs marked as "critical" by...
2
by: Mike Collins | last post by:
I cannot get the correct drop down list value from a drop down I have on my web form. I get the initial value that was loaded in the list. It was asked by someone else what the autopostback was...
0
by: =?Utf-8?B?am8uZWw=?= | last post by:
Hello All, I am developing an Input Methop (IM) for PocketPC / Windows Mobile (PPC/WM). On some devices the IM will not start. The IM appears in the IM-List but when it is selected from the...
1
by: sherifbk | last post by:
Problem description ============== - I have 4 clients and 1 server (SQL server) - 3 clients are Monitoring console 1 client is operation console - Monitoring console collects some data from...
9
by: AceKnocks | last post by:
I am working on a framework design problem in which I have to design a C++ based framework capable of solving three puzzles for now but actually it should work with a general puzzle of any kind and I...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.