Best Icon size for displaying in the tray

痞子三分冷 提交于 2019-12-29 05:21:06

问题


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?


回答1:


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.




回答2:


You should probably include both 32x32 and 16x16 icons and load the appropriate one at runtime:

Notification area icons should be high-DPI aware. An application should provide both a 16x16 pixel icon and a 32x32 icon in its resource file, and then use LoadIconMetric to ensure that the correct icon is loaded and scaled appropriately.

(source: MSDN)




回答3:


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



来源:https://stackoverflow.com/questions/8100334/best-icon-size-for-displaying-in-the-tray

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