[RESOLVED] [2005] Attaching a dynamic tooltip to a NotifyIcon
After spending some time Googling and MSDNing, I must say I have been unable to find pointers towards attaching a dynamic tooltip to a NotifyIcon instance.
The following code:
Code:
toolTip1.SetToolTip(Me.NotifyIcon_RealmTray, "Foobaz!")
Generates this error:
Error 1 Value of type 'System.Windows.Forms.NotifyIcon' cannot be converted to 'System.Windows.Forms.Control'. D:\Documents and Settings\xander\My Documents\Visual Studio 2005\Projects\RealmTray\RealmTray\MainForm.vb 136 29 RealmTray
So this is obviously not the way to go. However, what *is* the Right Way (tm) and could someone point me in the general direction, please? :)
Basically I want to have a nice little tooltip to popup whenever a user hovers over the system tray icon which contains some info regarding the status of one or more servers that are being monitored.
Thanks in advance,
Mightor
Re: [2005] Attaching a dynamic tooltip to a NotifyIcon
How about
Me.NotifyIcon_RealmTray.Text = "Foobaz!"
A notifyicon is just there to do that one thing, so it doesn't really need a tooltip... it sort of is one by itself. Anyway, I think that will do it.
Re: [2005] Attaching a dynamic tooltip to a NotifyIcon
18 is correct. The text property of the notifyicon control will be used as its tooltip automatically.
As an alternative, you can also do something like this
Code:
Private Sub NotifyIcon1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles NotifyIcon1.MouseMove
NotifyIcon1.ShowBalloonTip(5000, "Title", "Hello World", ToolTipIcon.Info)
End Sub
That gives you a balloon popup instead of just a tooltip, which can be a bit nicer in some situations. (can have a bold title and a predefined system icon in the balloon, versus only text)
Re: [2005] Attaching a dynamic tooltip to a NotifyIcon
Quote:
Originally Posted by mightor
After spending some time Googling and MSDNing, I must say I have been unable to find pointers towards attaching a dynamic tooltip to a NotifyIcon instance.
The following code:
Code:
toolTip1.SetToolTip(Me.NotifyIcon_RealmTray, "Foobaz!")
Generates this error:
Error 1 Value of type 'System.Windows.Forms.NotifyIcon' cannot be converted to 'System.Windows.Forms.Control'. D:\Documents and Settings\xander\My Documents\Visual Studio 2005\Projects\RealmTray\RealmTray\MainForm.vb 136 29 RealmTray
So this is obviously not the way to go. However, what *is* the Right Way (tm) and could someone point me in the general direction, please? :)
Basically I want to have a nice little tooltip to popup whenever a user hovers over the system tray icon which contains some info regarding the status of one or more servers that are being monitored.
Thanks in advance,
Mightor
Hi,
You can try this:
Code:
' The Text property sets the text that will be displayed,
' in a tooltip, when the mouse hovers over the systray icon.
notifyIcon1.Text = "Form1 (NotifyIcon example)"
notifyIcon1.Visible = True
Hope it helps,
sparrow1
Re: [2005] Attaching a dynamic tooltip to a NotifyIcon
Thanks for all the quick responses. I've opted for the nice Balloon tip kleinma suggested. The Me.NotifyIcon_RealmTray.Text = "Foobaz!" never worked for me which is why I posted. Also it would be kind of tricky to put more than a single line of text in there and all that stuff.
There isn't a way to disable the "pop" sound, is there?
Re: [2005] Attaching a dynamic tooltip to a NotifyIcon
No you can't disable the pop sound. It is actually whatever sound is assigned to "System Notification" in Windows.
You can see this in the control panel under the "sounds and audio devices" option, and then the "sounds" tab.
You can't selectively turn it off for just your balloon...
However you mentioned that assigning the text property never worked for you, which is odd, because it should. So you can either live with the system sound, or you can figure out why setting the .text property isn't working for you.
Re: [2005] Attaching a dynamic tooltip to a NotifyIcon
I can live with the pop sound. The extra functionality of the ShowBalloonTip far outweighs any annoyance the sound may cause. :)
Re: [2005] Attaching a dynamic tooltip to a NotifyIcon
Sounds good.
Mark the thread resolved using the threadtools menu above if all your questions about this specific topic have been answered ;)
Re: [2005] Attaching a dynamic tooltip to a NotifyIcon
Quote:
Originally Posted by kleinma
Sounds good.
Mark the thread resolved using the threadtools menu above if all your questions about this specific topic have been answered ;)
Way ahead of you :)