locked
Notify icon balloon tip. RRS feed

  • Question

  • Hi,

    i'd like to specify a question considering balloon tips. When using notify icons and we want to display something to the end user through the notify icon instance we use balloon tips. The code to create a notify icon and a balloon tip is fairly easy.

    public class Program
    {
        NotifyIcon notification;
        static void Main()
        {
            notification = new NotifyIcon();
            // the file has to be *.ico
            notification.Icon = Properties.Resources.MyIcon;
            // text property set to whatever i want to display when the mouse stays over the icon
            notification.Text = "My program";
            //finally set it to visible to see it
            notification.Visible = true;
    
            
    
            //something happens here and i want to show a balloon tip to the end user
            //there are 2 ways to do it according to MSDN library
            //One is to set the balloon tip text, icon, title spesifically 
            //and then call the ShowBalloonTip method and give an attribute of x milliseconds.
            //The other and faster way:
            ShowBalloonTip(8000, "MyTitle", "MyText", ToolTipIcon.Info);
            //But whatever method i use the balloon tip is refussing to show.
        }
    }

    I tried to add more milliseconds to the timeout in case of that was the problem but still nothing works. So i did some digging on the web and i read somewhere that is not quaranted 100% to show. So i am asking, is there something i can do to show it? Also, i checked if i can inherit from the NotifyIcon class to override perhaps it's ShowBalloonTip method but the class is sealed and can't be inherited. I tried the notify icon to both console application by referencing system.windows.forms and to windows form application, both with the same result. Is there something wrong with the code or what ? I am not interested in setting any type of context menu on it and events for it (that works), it is just refussing to show the balloon tip.

    Thursday, March 15, 2018 7:11 PM

Answers

  • Greetings Konstantinos.

    Try the following steps.

    1. Create a Forms application with a button.

    2. Drag a NotifyIcon from the toolbox onto the form.

    3. Click on the NotifyIcon that you just created and browse for an icon in the properties window. Your screen should look something like so.

    4. Run your program to see the icon in the system tray.

    5. Subscribe to the button's click event (I presume you know how to do this), and add the following code to the event handler.

          private void btnMyButton_Click(object sender, EventArgs e)
          {
             notifyIcon1.ShowBalloonTip(8000, "MyTitle", "MyText", ToolTipIcon.Info);
          }

    6. Run the program and click the button to see the BalloonTip.

    Good luck.

    • Proposed as answer by Stanly Fan Friday, March 16, 2018 2:45 AM
    • Marked as answer by Konstantinos pap Saturday, March 17, 2018 1:57 PM
    Thursday, March 15, 2018 11:13 PM
  • I fixed it ... It was the most rediculus thing ever... So at the end right side of the taskbar there is the notification area where all the notifications "spawn". And it just hit me to right click on it. I right click it and i have 4 choices 1 of which is "Enable notifications" ! And i'm like wtf !? Whatever, thank you all very much for your assistance, problem fixed.
    Saturday, March 17, 2018 1:56 PM

All replies

  • Greetings Konstantinos.

    Try the following steps.

    1. Create a Forms application with a button.

    2. Drag a NotifyIcon from the toolbox onto the form.

    3. Click on the NotifyIcon that you just created and browse for an icon in the properties window. Your screen should look something like so.

    4. Run your program to see the icon in the system tray.

    5. Subscribe to the button's click event (I presume you know how to do this), and add the following code to the event handler.

          private void btnMyButton_Click(object sender, EventArgs e)
          {
             notifyIcon1.ShowBalloonTip(8000, "MyTitle", "MyText", ToolTipIcon.Info);
          }

    6. Run the program and click the button to see the BalloonTip.

    Good luck.

    • Proposed as answer by Stanly Fan Friday, March 16, 2018 2:45 AM
    • Marked as answer by Konstantinos pap Saturday, March 17, 2018 1:57 PM
    Thursday, March 15, 2018 11:13 PM
  • Did that exact same thing as you described but i get nothing. In the tray menu it seems like it tries to pop up and then something immediately shut it down. Any suggestions? The code seems to work fine even though it is exactly what i had above. Could this be related to the .NetFramework i am targeting ? I am targeting .Net Framework 4.5.2
    Friday, March 16, 2018 12:03 PM
  • Ok so i changed the .NetFramework from 4.5.2 to 3.0 then to 4.5 after that 4.6 and the same thing happens, so it is not the framework. Something is blocking it from showing and i can't find out what. It doesn't hit any exceptions, the code is working flawlessly. I think it has something to do with the OS or something. Not really sure. Do you know any way to find out what is blocking it?

    Friday, March 16, 2018 5:42 PM
  • Ok so i changed the .NetFramework from 4.5.2 to 3.0 then to 4.5 after that 4.6 and the same thing happens, so it is not the framework. Something is blocking it from showing and i can't find out what. It doesn't hit any exceptions, the code is working flawlessly. I think it has something to do with the OS or something. Not really sure. Do you know any way to find out what is blocking it?

    Maybe you can test the same thing in C++ .

    You can launch TrayIconTest.exe in \Release from TrayIconTest.zip

    (test done with VS 2015 on Windows 10)


    • Edited by Castorix31 Friday, March 16, 2018 6:31 PM
    Friday, March 16, 2018 6:30 PM
  • I downloaded this i saw the code, even though i don't understand much of c++ i pretty much understood what happens in there.. But that didn't work either. The sound works but no balloon tip showed once more.. I think some setting from my computer blocks it. But i have no idea what could cause that.. I checked the settings that concern the process bar and the tray icons but nothing seemed tempered with. Maybe some registry value?
    Friday, March 16, 2018 7:47 PM
  • They can be disabled on some OS

    (How to Enable or Disable Balloon Notifications in Vista, Windows 7, and Windows 8)

    (the registry doesn't work on mine (Windows 10))

    Friday, March 16, 2018 9:08 PM
  • Your icon is probably going into the hidden part of the tray. Click on the little up-arrow (the one that says "Show hidden icons" when you hover over it) and you should see your icon in the pop-up. You can then go to "Customise" and make your icon always visible.

    Note that even if your icon is hidden, clicking the button on your application should un-hide it long enough to show the Balloon Tip.

    Saturday, March 17, 2018 12:51 AM
  • I tried every solution i found and nothing works... I copied the debug file containing my exe file from my example project and placed it to another pc and it works.. So the problem is on my pc.. Whatever, i can deal with that...
    Saturday, March 17, 2018 11:08 AM
  • The registry works in fact, but Explorer must be re-started.
    Saturday, March 17, 2018 11:19 AM
  • Also guys other notifications such as windows defender, windows update, battery warning etc works. Just my application's notification wont work on my pc for some reason. And the other one i downloaded.

    Maybe it could be other application permission to show? Maybe just the system has permissions to show notifications.. The same code on another pc with the same OS and settings works fine.

    Saturday, March 17, 2018 11:45 AM
  • >>The registry works in fact, but Explorer must be re-started.
    I just restarted the explorer and nothing changed.. Same thing it tries to pop up and something shuts it down.. It is in the hidden icons and when i click the button it goes next to the "always shown" icons but it immediately falls back to the hidden without showing the notification. OS is windows 10 professional so the notification shouldn't pop up like in windows 7 but in the notification area (the far right icon after the date and time.) Also bitdefender's and malwarebyte's notifications can be viewed there.
    Saturday, March 17, 2018 11:56 AM
  • In my test, I did :

    Start TrayIconTest.exe : it shows the Balloon Tooltip

    Execute Disable_Notifications.reg

    Re-start Explorer

    Start TrayIconTest.exe : it doesn't show the Balloon Tooltip

    (then Enable_Notifications.reg, Re-start Explorer, to come back to normal)


    • Edited by Castorix31 Saturday, March 17, 2018 12:07 PM
    Saturday, March 17, 2018 12:05 PM
  • In my test, I did :

    Start TrayIconTest.exe : it shows the Balloon Tooltip

    Execute Disable_Notifications.reg

    Re-start Explorer

    Start TrayIconTest.exe : it doesn't show the Balloon Tooltip

    (then Enable_Notifications.reg, Re-start Explorer, to come back to normal)


    In fact when i disable it, it doesn't even try to pop up. But when i enable it, it just tries to pop up and something blocks it just as i said before.

    So in fact the registry works, but the problem is not there.
    Saturday, March 17, 2018 12:11 PM
  • Note that even if your icon is hidden, clicking the button on your application should un-hide it long enough to show the Balloon Tip.

    As Ante Meridian said if my icon is hidden when i click the button it should unhide it long enough to show the balloon tip. But to me it unhides it for a millisecond and it goes back to the hidden icons without showing the balloon tip. I had 8000 milliseconds (8 seconds) then changed it to 80000 milliseconds yet the same thing happens. (I hope that describes the issue i'm dealing with more detail.)



    Saturday, March 17, 2018 12:21 PM
  • I fixed it ... It was the most rediculus thing ever... So at the end right side of the taskbar there is the notification area where all the notifications "spawn". And it just hit me to right click on it. I right click it and i have 4 choices 1 of which is "Enable notifications" ! And i'm like wtf !? Whatever, thank you all very much for your assistance, problem fixed.
    Saturday, March 17, 2018 1:56 PM