Windows 10 NotifyIcon Icon always looks very pixilated

孤者浪人 提交于 2020-01-02 07:04:09

问题


I am having trouble making a NotifyIcon in Windows 10 whose icon resource looks anything but a blurry mess.

This happens with both icons from the SystemIcons class, or my own using Properties.Resources. I have tried creating a new instance of the icon with the Icon (Icon original, int width, int height) constructor, and all sorts of other mad things, including this nugget:

Icon ico = Icon.FromHandle((new Icon(Resources.InfoIcon, 256, 256).ToBitmap()).GetHicon());

to no avail. Any advice would be appreciated!


回答1:


The poor icon in the screenshot is easy to address, you forgot to set the NotifyIcon.BalloonTipIcon property. Or use the NotifyIcon.ShowBalloonTip() method overload that takes ToolTipIcon. With ToolTipIcon.Info you'll get the high resolution system default icon. For example:

    notifyIcon1.ShowBalloonTip(5000, "eDIDIO", 
        "Connected successfully!", ToolTipIcon.Info);

Which produces:

If you want your own icon to show up in this notification "balloon" then you have to work around a restriction in the ResourceManager.GetObject() method. Which is what you are using when you write "Resources.InfoIcon". GetObject() does not have enough arguments to be selective about the icon size you prefer. Use the code shown in this answer. Never use GetHicon() btw, it does a very poor job at color palette mapping and can only produce a 16 color icon.



来源:https://stackoverflow.com/questions/35242400/windows-10-notifyicon-icon-always-looks-very-pixilated

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!