在托盘中显示的最佳图标大小 [英] Best Icon size for displaying in the tray

查看:35
本文介绍了在托盘中显示的最佳图标大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个 Delphi 程序,它将在托盘"上显示一个图标.我正在艰难地"做这件事(使用 Shell_NotifyIcon api 等而不是组件,原因不在此处).它工作正常,但有时在某些系统中图标似乎有点模糊".现在,我已经尝试使用 16x16 bmp、32x32 等.似乎系统将其缩小到所需的大小,但结果因操作系统版本(或其他版本)而异....

对于使用 ListImage 中的 Shell_NotifyIcon 提取和显示在托盘上的 BMP 的最佳尺寸和颜色深度,你们有没有任何经验?

解决方案

为了获得最佳效果,您应该使用具有部分透明度的 32bpp 图标.

图标使用较小的系统尺寸.通过调用传递 SM_CXSMICONGetSystemMetrics 获取此信息.例如,如果您使用字体缩放,这可以是 20 像素而不是更常见的 16 像素.我从来没有找到关于这个事实的 MS 文档,但你可以通过反复试验很容易地自己验证它.不是一个真正愉快的事态,但它就是这样.

更新: TOndrej 指出,LoadIconMetric 的文档默认通知区域图标是小图标尺寸.我不明白为什么通知图标中不包含此信息.

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?

解决方案

You should be using 32bpp icons with partial transparency for best effect.

The icon uses the small system size. Get this by calling GetSystemMetrics passing SM_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.

这篇关于在托盘中显示的最佳图标大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆