如何向 Windows 询问系统托盘图标的大小? [英] How do I ask Windows for the size of system tray icons?

查看:30
本文介绍了如何向 Windows 询问系统托盘图标的大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到我的应用程序向 Windows 托盘发送大小为 16x16 像素的图标——而我的 Vista PC 我有一个双宽任务栏,它似乎以 18x18 像素显示图标.我的应用程序图标上调整大小的工件看起来很糟糕.如何询问 Windows 图标的大小?

I noticed that my app sends icons to the Windows tray with a size of 16x16 pixels--and my Vista PC I've got a doublewide taskbar that appears to show icons at 18x18. The resizing artifacts on my app's icon look awful. How can I ask Windows what size the icons should be?

我正在动态生成图标,并带有像素字体文本叠加层.动态生成一堆图标大小似乎很浪费,因此最好避免构建具有所有可能"大小的图标(我什至不确定它们是什么).

I'm generating the icon dynamically, with a pixel font text overlay. It seems wasteful to generate a bunch of icon sizes dynamically, so it would be nice to avoid building an icon with all the "possible" sizes (not that I'm even sure what those are).

GetSystemMetrics(SM_CXSMICON) 返回 16——错误的值.

GetSystemMetrics(SM_CXSMICON) returns 16--the incorrect value.

GetThemeBackgroundContentRect 也没有帮助.

GetThemeBackgroundContentRect didn't help, either.

推荐答案

你最好的选择可能是 GetThemeBackgroundContentRectTBN_BACKGROUND 作为 iPartId 传递给托盘通知背景.

Your best bet may be GetThemeBackgroundContentRect passing TBN_BACKGROUND as iPartId for the tray notify background.

GetThemeBackgroundContentRect 应返回由当前主题定义的大小,该大小可用于绘图而不会与父元素的边框重叠.如果我没看错,那将是允许的最大尺寸的通知图标,并且可能是正在使用的尺寸.

GetThemeBackgroundContentRect should return the size defined by the current theme that may be used for drawing without overlapping the borders of the parent element. If I'm reading this correctly, that would be the largest sized notification icon permissible and presumably the size that is being used.

使用多个 DPI 设置进行测试可能是判断这是否返回正确值的最简单方法.

Testing with multiple DPI settings is probably the easiest way to tell if this is returning the correct value.

这篇关于如何向 Windows 询问系统托盘图标的大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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