By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,594 Members | 3,291 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,594 IT Pros & Developers. It's quick & easy.

RE: NotifyIcon Click events not firing

P: n/a
Hello Jason,

Thanks for using Microsoft Newsgroup Support Service, my name is Ji Zhou
[MSFT] and I will be working on this issue with you.

I have tried to but cannot reproduce your issue on my side. From your
codes, I think the logical is, every time the Timer's elapsed event fires,
we call the Check_For_Version_Update() function. From the
Check_For_Version_Update() function, we judge a condition statement, and
determine whether to call Notification() function. In the Notification()
function, we show our balloon tip, right?

For I do not see your codes in the Check_For_Version_Update() function. I
write my simulated version to test on my side. The whole codes are as
follows,

Public Class Form1
Dim WithEvents tmrUpdateCheckTimer As System.Timers.Timer

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
tmrUpdateCheckTimer = New System.Timers.Timer()
tmrUpdateCheckTimer.Interval = 3000
tmrUpdateCheckTimer.Enabled = True
End Sub
Private Sub tmrUpdateCheckTimer_Elapsed(ByVal sender As Object, ByVal e
As System.Timers.ElapsedEventArgs) Handles tmrUpdateCheckTimer.Elapsed
'When this timer event is triggered, check for updates and notify
the user.
'Disable the timer for the rest of the session.
Me.tmrUpdateCheckTimer.Enabled = False
If My.Computer.Network.IsAvailable Then Check_For_Version_Update()
End Sub

Private Sub Check_For_Version_Update()
Dim findUpdateVersion = True
If (findUpdateVersion) Then
Notification("Test Title", "Test Body", "http://localhost")
End If
End Sub

Public Sub Notification(ByVal Title As String, ByVal Body As String,
Optional ByVal ActionURL As String = "")
Me.NotifyIcon.BalloonTipTitle = Title
Me.NotifyIcon.BalloonTipText = Body
If Len(ActionURL) 0 Then
NotifyIcon.Tag = ActionURL
Else
NotifyIcon.Tag = ""
End If
Me.NotifyIcon.Visible = True
Me.NotifyIcon.ShowBalloonTip(9)
End Sub

Private Sub NotifyIcon_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles NotifyIcon.Click
MsgBox("Clicked 2", MsgBoxStyle.OkOnly, "Test: Click Detection")
Call NotifyIcon_BalloonTipClicked(sender, e)
End Sub

Private Sub NotifyIcon_BalloonTipClicked(ByVal sender As Object, ByVal
e As System.EventArgs) Handles NotifyIcon.BalloonTipClicked
MsgBox("Clicked", MsgBoxStyle.OkOnly, "Test: Click Detection")
If Len(NotifyIcon.Tag.ToString) 0 Then
Dim myTargetURL As String = NotifyIcon.Tag.ToString
System.Diagnostics.Process.Start(myTargetURL)
Application.DoEvents()
End If
Me.NotifyIcon.Visible = False
End Sub
End Class

No matter I run the application within Visual Studio or deploy it and run
it at client machines. It always works as expected. The click event of
NotifyIcon and BallonTip fires OK. I can see the message box to pop up, as
well as the target site's launching. One important thing to be mentioned is
that, in the Notification() function, I have changed the codes

If Len(ActionURL) 0 Then NotifyIcon.Tag = ActionURL Else
NotifyIcon.Tag = ""

to

If Len(ActionURL) 0 Then
NotifyIcon.Tag = ActionURL
Else
NotifyIcon.Tag = ""
End If

Actually, without the End If statement, the NotifyIcon.Tag="" will always
be executed. So, at the later time, the target site will never be launched.
This may be problematical in the design logical, but I do not think it will
result into the message box's not poping up.

To do a future investigation on this issue and narrow down the problem,
would you mind to send me an setup msi file of your test project? So, I can
try to setup the application on my side, and run it to see what the problem
is there. You can access me by this email address, v-****@microsoft.com

Have a nice day!

Best regards,
Ji Zhou (v-****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subs...#notifications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://support.microsoft.com/select/...tance&ln=en-us.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Oct 31 '08 #1
Share this Question
Share on Google+
1 Reply


P: n/a
reply.

The IF-Then-Else statement that you noticed on two lines is actually on a
single line in my code and works just fine. But, I re-formatted it and added
the End If anyways.

I created a temporary application and pasted your code into it, added a
NotifyIcon to the form and assigned an icon to it for testing purposes. Both
the NotifyIcon Click event and the NotifyIcon.BaloonClick events worked
correctly under VS2008 and as a standalone application. So, what's the
difference between my original code and this test application? I started
experimenting a bit.

I dug into the form designer code and found the following:

My original code was:
'
'NotifyIcon
'
Me.NotifyIcon.BalloonTipIcon = System.Windows.Forms.ToolTipIcon.Info
Me.NotifyIcon.BalloonTipText = "Click to visit the website for more
information."
Me.NotifyIcon.BalloonTipTitle = "An Update is available for IAS"
Me.NotifyIcon.Icon = CType(resources.GetObject("NotifyIcon.Icon"),
System.Drawing.Icon)
Me.NotifyIcon.Text = "IAS Notifications"

The test app was:
'
'NotifyIcon
'
Me.NotifyIcon.Icon = CType(resources.GetObject("NotifyIcon.Icon"),
System.Drawing.Icon)
Me.NotifyIcon.Text = "NotifyIcon"
Me.NotifyIcon.Visible = True
I pasted the test app code over the original app code as an experiment.
Then I set the initial visibility to false. Now, when I run the app, the
events appear to fire correctly under VS2008 and on two other machines.

So, I assume that one of the differences above had an un-intended side
effect that was causing the failure.

Thanks for your help.

Jason
"""Ji Zhou [MSFT]""" wrote:
Hello Jason,

Thanks for using Microsoft Newsgroup Support Service, my name is Ji Zhou
[MSFT] and I will be working on this issue with you.

I have tried to but cannot reproduce your issue on my side. From your
codes, I think the logical is, every time the Timer's elapsed event fires,
we call the Check_For_Version_Update() function. From the
Check_For_Version_Update() function, we judge a condition statement, and
determine whether to call Notification() function. In the Notification()
function, we show our balloon tip, right?

For I do not see your codes in the Check_For_Version_Update() function. I
write my simulated version to test on my side. The whole codes are as
follows,

Public Class Form1
Dim WithEvents tmrUpdateCheckTimer As System.Timers.Timer

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
tmrUpdateCheckTimer = New System.Timers.Timer()
tmrUpdateCheckTimer.Interval = 3000
tmrUpdateCheckTimer.Enabled = True
End Sub
Private Sub tmrUpdateCheckTimer_Elapsed(ByVal sender As Object, ByVal e
As System.Timers.ElapsedEventArgs) Handles tmrUpdateCheckTimer.Elapsed
'When this timer event is triggered, check for updates and notify
the user.
'Disable the timer for the rest of the session.
Me.tmrUpdateCheckTimer.Enabled = False
If My.Computer.Network.IsAvailable Then Check_For_Version_Update()
End Sub

Private Sub Check_For_Version_Update()
Dim findUpdateVersion = True
If (findUpdateVersion) Then
Notification("Test Title", "Test Body", "http://localhost")
End If
End Sub

Public Sub Notification(ByVal Title As String, ByVal Body As String,
Optional ByVal ActionURL As String = "")
Me.NotifyIcon.BalloonTipTitle = Title
Me.NotifyIcon.BalloonTipText = Body
If Len(ActionURL) 0 Then
NotifyIcon.Tag = ActionURL
Else
NotifyIcon.Tag = ""
End If
Me.NotifyIcon.Visible = True
Me.NotifyIcon.ShowBalloonTip(9)
End Sub

Private Sub NotifyIcon_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles NotifyIcon.Click
MsgBox("Clicked 2", MsgBoxStyle.OkOnly, "Test: Click Detection")
Call NotifyIcon_BalloonTipClicked(sender, e)
End Sub

Private Sub NotifyIcon_BalloonTipClicked(ByVal sender As Object, ByVal
e As System.EventArgs) Handles NotifyIcon.BalloonTipClicked
MsgBox("Clicked", MsgBoxStyle.OkOnly, "Test: Click Detection")
If Len(NotifyIcon.Tag.ToString) 0 Then
Dim myTargetURL As String = NotifyIcon.Tag.ToString
System.Diagnostics.Process.Start(myTargetURL)
Application.DoEvents()
End If
Me.NotifyIcon.Visible = False
End Sub
End Class

No matter I run the application within Visual Studio or deploy it and run
it at client machines. It always works as expected. The click event of
NotifyIcon and BallonTip fires OK. I can see the message box to pop up, as
well as the target site's launching. One important thing to be mentioned is
that, in the Notification() function, I have changed the codes

If Len(ActionURL) 0 Then NotifyIcon.Tag = ActionURL Else
NotifyIcon.Tag = ""

to

If Len(ActionURL) 0 Then
NotifyIcon.Tag = ActionURL
Else
NotifyIcon.Tag = ""
End If

Actually, without the End If statement, the NotifyIcon.Tag="" will always
be executed. So, at the later time, the target site will never be launched.
This may be problematical in the design logical, but I do not think it will
result into the message box's not poping up.

To do a future investigation on this issue and narrow down the problem,
would you mind to send me an setup msi file of your test project? So, I can
try to setup the application on my side, and run it to see what the problem
is there. You can access me by this email address, v-****@microsoft.com

Have a nice day!

Best regards,
Ji Zhou (v-****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subs...#notifications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://support.microsoft.com/select/...tance&ln=en-us.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Oct 31 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.