Can someone please explain to me why no matter what value I set the timeout value to for the BalloonTip of a NotificationIcon in my project, it always shows for the same length of time
Below is the line of code to call the BalloonTip:
nfyNotify.ShowBalloonTip(1000,
"SubSelect Watchdog", _ "SubSelect watchdog will remain in the notification " & vbCrLf & _ "bar until it successfully allocates you to your first" & vbCrLf & _ "preferences or you cancel the operation.", ToolTipIcon.Info)
BalloonTip
#Sid
Ok, well I worked out my problem. Apparently, there is a minimum and maximum value that you can set for the BalloonTip timeout. These values are set by the operating system, and are typically 10 to 30secs. I haven't found a way to change these values. Re: your problem, try the following. As you are invalidating the BalloonTip every time you call a new ShowBalloonTip method, the BalloonTipClosed method is getting called without the help of the user. Therefore, by employing a boolean to tell your program when the BalloonTip is being updated, it can distinguish between a user clicking the close button and the routine update of the time. Also, you might want to disable the Timer rather than just changing a flag when the user clicks the close button so that you're not using up memory with a timer not executing any code. Hope this helps ;)
-----------------------------------------------------------
Public
Class BalloonTipTimePrivate
startTime As Date Private Invalidated As BooleanPrivate Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim timeSpent As TimeSpan = DateTime.Now - startTime
Dim toopTipText As String = timeSpent.Hours & ":" & timeSpent.Minutes & ":" & timeSpent.Seconds
'Let your program know it's about to update the BalloonTipInvalidated =
TrueNotifyIcon1.ShowBalloonTip(500,
"Yout Status", toopTipText, ToolTipIcon.None) End SubPrivate Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
startTime = DateTime.Now
End SubPrivate Sub NotifyIcon1_BalloonTipClosed(ByVal sender As Object, ByVal e As System.EventArgs) Handles NotifyIcon1.BalloonTipClosed
If Invalid = False Then 'This method wasn't called by updating the BalloonTip
Timer1.Enabled = False
End IfInvalid =
False 'Finished updating the BalloonTip End SubEnd
ClassMatthew_M81
I found that setting the notifyIcon.Visible = false and then notifyIcon.Visible = true forces the bubble to disappear. It's a kludge but it works.
private Sub ForceBubbleToDisappear()
notifyIcon1.Visible = false
notifyIcon1.Visible = true
End Sub
TonyV
GanjaDoc
the timeout value may only means the balloon's timeout time, not the time it shows.
also I got another problem:
I used the timer and set its Interval property to 1000 so that I can keep the balloontip text goes like a clock. I used the code below and it works:
-------------------------------------------------------------
private void timer_Tick(object sender, EventArgs e)
{
if (!isClicked)
{
TimeSpan timeSpent = DateTime.Now - startTime;
string toopTipText = timeSpent.Hours + ":" + timeSpent.Minutes + ":" + timeSpent.Seconds;
notifyIcon.ShowBalloonTip(500, "Yout Status", toopTipText, ToolTipIcon.None);
}
}
private void notifyIcon_BalloonTipClosed(object sender, EventArgs e)
{
isClicked = false;
}
---------------------------------------------------------------
the problem is: when the user closes the balloontip manually, the balloontip still shows at the next second! this is because the BalloonTipClosed event is invoked every second. so how do I distinguish the manual close from the automatical close
sorry for putting my issue here, I really hope someone can help me :)