NotifyIcon 使用哪种格式和大小的图标
我找不到有关系统托盘图标的任何信息,它们应该采用什么尺寸才能获得最佳质量。我应该使用不止一种尺寸(16x16、32x32、64x64)吗?
我目前使用 16x16 .ICO 图标,它们看起来很混乱。
i couldn't find any information regarding system tray icons, what size should they be in to get the best possible quality. Should i use more than one size (16x16,32x32,64x64)?
I'm currently using 16x16 .ICO icons and they look disorted.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
它们是小图标 (
ICON_SMALL
)。您可以通过致电了解尺寸:我认为假设它们是正方形是相当安全的,但如果您偏执,那么您可以随时查询
SM_CYSMICON
。在我的 Windows 7 机器上,它们的大小为 16px。但如果您使用字体缩放,那么它们会更大。对于 125% 的字体缩放(例如大字体),您将需要一个 20px 的图标。
如果您手头没有 20px 版本,那么最好的方法是即时生成一个版本,并将您的 16px 版本放在新的 20px 图标的中间。
更新
NOTIFYICONDATA
建议使用LoadIconMetric
传递LIM_SMALL
,这相当于我上面概述的方法。但是,
NOTIFYICONDATA
主题还表示使用仅包含 16px 和 32px 版本图标的图标资源。这个建议是虚假的,因为任何人都可以亲眼看到,大字体下的通知图标是 20px 图标,而LoadIconMetric
的比例从 32 到 20。我建议提供 16、20、24、32px 版本。在 XP 上,
LoadIconMetric
不存在,因此您需要实现一个后备例程。They are small icons (
ICON_SMALL
). You can find out the size by calling:I think it's pretty safe to assume that they are square, but if you are paranoid then you can always inquire about
SM_CYSMICON
.On my Windows 7 machine they are 16px in size. But if you are using font scaling then they will be larger. For a 125% font scaling (e.g. large fonts) you will need a 20px icon.
If you don't have a 20px version at hand then the best approach is to generate one on the fly and put your 16px version in the middle of the new 20px icon.
Update
The documentation of
NOTIFYICONDATA
recommends usingLoadIconMetric
passingLIM_SMALL
which is equivalent to the approach I outline above.However, the
NOTIFYICONDATA
topic also says to use an icon resource containing just16px and 32px versions of the icon. That advice is bogus because, as anyone can see for themselves, notification icons under large fonts are 20px icons andLoadIconMetric
will have scale from 32 to 20. I would recommend supplying 16, 20, 24, 32px versions.On XP
LoadIconMetric
doesn't exist so you'd need to implement a fallback routine.我认为最好创建多种尺寸的图标,然后让 Windows 选择最好的一个。您永远无法确定系统托盘有多大,因为不同的用户可能有不同的设置。
这也可能是你的内容看起来扭曲的原因。假设您使用的是 16x16,但您已将 Windows 设置为显示它们 18x18。如果您没有提供 18x18 图标,它会变形。
请参阅此问题并拉里·奥斯特曼的回答。
I believe it's best to create your icon in multiple sizes and let Windows choose the best one. You're never sure how large the system tray is, because different users may have different settings.
That could also be the reason yours seems distorted. Say you're using a 16x16, but you've set Windows to display them 18x18. If you haven't provided an 18x18 icon, it'll be distorted.
See this question and Larry Osterman's answer.