问题
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