Results 1 to 9 of 9

Thread: [RESOLVED] [2005] Attaching a dynamic tooltip to a NotifyIcon

  1. #1

    Thread Starter
    Lively Member mightor's Avatar
    Join Date
    Apr 2007
    Location
    Turn around, I'm right behind you...
    Posts
    99

    Resolved [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

  2. #2
    Fanatic Member
    Join Date
    Nov 2006
    Posts
    675

    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..."

  3. #3
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    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)

  4. #4
    PowerPoster sparrow1's Avatar
    Join Date
    May 2005
    Location
    Globetrotter
    Posts
    2,820

    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
    Wkr,
    sparrow1

    If I helped you, don't forget to Rate my post. Thank you

    I'm using Visual Studio.Net 2003 and
    2005
    How to learn VB.Net Create setup with VB 2005 Drawing for beginners VB.Net Tutorials GDI+ Tutorials
    Video's for beginners

  5. #5

    Thread Starter
    Lively Member mightor's Avatar
    Join Date
    Apr 2007
    Location
    Turn around, I'm right behind you...
    Posts
    99

    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.

  6. #6
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    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.

  7. #7

    Thread Starter
    Lively Member mightor's Avatar
    Join Date
    Apr 2007
    Location
    Turn around, I'm right behind you...
    Posts
    99

    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.

  8. #8
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    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

  9. #9

    Thread Starter
    Lively Member mightor's Avatar
    Join Date
    Apr 2007
    Location
    Turn around, I'm right behind you...
    Posts
    99

    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
    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
  •  



Click Here to Expand Forum to Full Width