|
-
Apr 25th, 2007, 02:09 PM
#1
Thread Starter
Lively Member
[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
-
Apr 25th, 2007, 02:24 PM
#2
Fanatic Member
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.
VB.Net 2008
.Net Framework 2.0
"Must you breathe? 'Cause I need heaven..."
-
Apr 25th, 2007, 02:29 PM
#3
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)
-
Apr 25th, 2007, 02:30 PM
#4
Re: [2005] Attaching a dynamic tooltip to a NotifyIcon
 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
-
Apr 25th, 2007, 02:37 PM
#5
Thread Starter
Lively Member
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?
What the world needs is more geniuses with humility, there are so few of us left.
If my post was accidentally useful, please rate it as such, thanks!
Mon aéroglisseur est plein des anguilles.
-
Apr 25th, 2007, 02:42 PM
#6
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.
-
Apr 25th, 2007, 02:46 PM
#7
Thread Starter
Lively Member
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.
What the world needs is more geniuses with humility, there are so few of us left.
If my post was accidentally useful, please rate it as such, thanks!
Mon aéroglisseur est plein des anguilles.
-
Apr 25th, 2007, 02:48 PM
#8
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
-
Apr 25th, 2007, 02:56 PM
#9
Thread Starter
Lively Member
Re: [2005] Attaching a dynamic tooltip to a NotifyIcon
 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
What the world needs is more geniuses with humility, there are so few of us left.
If my post was accidentally useful, please rate it as such, thanks!
Mon aéroglisseur est plein des anguilles.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|