我正在开发一个 Delphi 程序,它将在“托盘”上显示一个图标。我正在“艰难地”做这件事(使用 Shell_NotifyIcon api 等而不是组件,出于此处要点之外的原因)。它工作正常,但有时在某些系统中图标似乎有点“模糊”。现在,我已经尝试使用 16x16 bmp、32x32 等。似乎系统将其缩小到所需的大小,但结果根据操作系统版本(或者可能还有其他版本)而有所不同......
有任何对于使用 ListImage 中的 Shell_NotifyIcon 提取并显示在托盘上的 BMP 的最佳大小和颜色深度,您有什么经验吗?
I am working on a Delphi program which will display an icon on the "tray". I am doing it "the hard way" (using the Shell_NotifyIcon api, etc and not a component, for reasons outside the point here). It's working fine but sometimes it seems like the icon is a little "blurry" in some systems. Now, I have experimented using 16x16 bmp, 32x32, etc. It seems like the system scales it down to the needed size, but the results are different depending on the OS version (or perhaps something else as well)....
Have any of you any experience about the best size and color depth of a BMP to be extracted and displayed on the tray using Shell_NotifyIcon from a ListImage?
发布评论
评论(3)
为了获得最佳效果,您应该使用部分透明的 32bpp 图标。
该图标使用较小的系统尺寸。通过调用
GetSystemMetrics
传递SM_CXSMICON
来获取此信息。例如,如果您使用字体缩放,则可以是 20 像素,而不是更常见的 16 像素。我从未找到过有关此事实的 MS 文档,但您可以通过反复试验轻松地自行验证。这并不是一种幸福的状态,但事实就是如此。更新: TOndrej 指出,
LoadIconMetric
的文档默认通知区域图标为小图标尺寸。我不明白为什么此信息不包含在通知图标的信息中。You should be using 32bpp icons with partial transparency for best effect.
The icon uses the small system size. Get this by calling
GetSystemMetrics
passingSM_CXSMICON
. If you use font scaling this can be, for example, 20px rather than the more common 16px. I've never found MS documentation for this fact but you can readily verify it for yourself by trial and error. Not really a happy state of affairs, but it is what it is.Update: TOndrej points out that the docs for
LoadIconMetric
gives tacit approval of the notification area icon being small icon size. I don't understand why this information is not included with that for notification icons.您可能应该包含 32x32 和 16x16 图标并在运行时加载适当的图标:
(来源:MSDN)
You should probably include both 32x32 and 16x16 icons and load the appropriate one at runtime:
(source: MSDN)
建议使用单个
*.ico
文件作为应用图标。*.ico
文件可以存储不同尺寸的图标,如16、32、256等。您可以在线将不同的图像文件转换为ico格式此处。对于托盘图标 16x16 或 32x32 ico 适合。
图标的官方 msdn 指南:图标在 Windows 中
A single
*.ico
file is recommended for app icons.*.ico
file can store different sizes of icons like 16, 32, 256 etc. You can convert different image files to ico format online here.For tray icon 16x16 or 32x32 ico would fit.
Official msdn guide for icons: icons in Windows