locked
NotifyIcon's icon is sometimes blurry RRS feed

  • Question

  • I put together a simple little NotifyIcon program based on modified WinForms technology and everything works just fine for me. However, on one machine at my client's company the icon that shows in the notification tray is first crystal clear and then blurred, as though the system had selected a large 128x128 image the next and dynamically resized it to fit on the notification tray area. I can see no reason why such a thing would happen. The icon was built with 16x16 and so on up to 256x256 so the system should be able to get the appropriate sized image out of the icon. Also, if it was having trouble getting the best match, why would it toggle between clear and blurry on each user logon?

    This is such simple code it is hard to see what could go wrong. The icon has multiple resolutions and is an embedded resource. It is instantiated in the standard fashion, by referencing the resource.

    TrayIcon.Icon = Properties.Resources.icon_key_small;
    

    So, any ideas why an icon might sometimes display in a blurry fashion on some machines?


    Richard Lewis Haggard

    Wednesday, August 2, 2017 12:26 AM

All replies


  • Hi Richard.Haggard,

    From your description, I try to restore your issue. however, it did not appear.

    But, I found when I use the following code.

    TrayIcon.Icon = Properties.Resources.icon_key_small;
    

    I will get the following result (a vague picture).

    So, I change the code as below:

     TrayIcon.Icon = new Icon(Properties.Resources.icon_key_small, SystemInformation.SmallIconSize);
    

    I will get a clear picture.

    >>So, any ideas why an icon might sometimes display in a blurry fashion on some machines?

    As far as I know, The problem may be cause with directly using the icon in your resources is that instead of choosing the right icon version in you icon file, the framework simply scales the default icon version to whatever size the notification area needs.

    So, you can try to instead of directly setting your NotifyIcon. You can create a new Icon instance and choose a specific icon size in your icon resource(Using SystemInformation.SmallIconSize will get you the size the notification area needs.).

    TrayIcon.Icon = new Icon(Properties.Resources.icon_key_small, SystemInformation.SmallIconSize);

    SystemInformation.SmallIconSize always returns the right icon size.

    Best Regards,

    Yohann Lu



    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, August 2, 2017 6:32 AM