是否有 GetThemeColor / Visual Styles API 的有效参数组合列表

发布于 2024-08-13 21:52:43 字数 1026 浏览 11 评论 0原文

我正在尝试检索任务栏和/或我的应用程序主窗口的背景和文本颜色。事实证明,Windows 7 没有返回正确的颜色。如果我切换到粉红色主题,Windows 7 仍然会返回浅蓝色的窗口标题,尽管事实并非如此。这种情况发生在使用

GetSysColor(COLOR_ACTIVECAPTION); 

以及使用 HTHEME hTheme = OpenThemeData(hwnd, L"WINDOW");

HRESULT result = GetThemeColor(      
                hTheme,
                WP_CAPTION, 
                CS_ACTIVE, 
                TMT_FILLCOLORHINT, 
                &color);

此外,我发现自己尝试各种参数组合来找出标题文本的颜色。我知道 Microsoft 页面

属性标识符部件和状态

,但大多数是这数百个参数的组合均无效。是否有可以使用哪些组合的列表和/或描述?

 GetThemeColor(      
                    hTheme,
                    WP_CAPTION, // BP_PUSHBUTTON,
                    CS_ACTIVE, 
                    TMT_CAPTIONTEXT,
                    &color);

返回“未找到元素”。

I am trying to retrieve the background and text color of the taskbar and/or my applications main window. It turned out, that Windows 7 does not return the correct colors. If i i.e. switch to a pink theme, Windows 7 still returns light blue for window caption although thats not true. This happens using

GetSysColor(COLOR_ACTIVECAPTION); 

as well as using
HTHEME hTheme = OpenThemeData(hwnd, L"WINDOW");

HRESULT result = GetThemeColor(      
                hTheme,
                WP_CAPTION, 
                CS_ACTIVE, 
                TMT_FILLCOLORHINT, 
                &color);

Moreover i find myself trying various combinations of parameters to find out the color of the caption text. I know microsofts pages

Property Identifiers and Parts and States

but most combination of these hundreds of parameters are invalid. Is there any list and/or description which combinations can be used?

I.e.

 GetThemeColor(      
                    hTheme,
                    WP_CAPTION, // BP_PUSHBUTTON,
                    CS_ACTIVE, 
                    TMT_CAPTIONTEXT,
                    &color);

returns "Element not found".

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

温馨耳语 2024-08-20 21:52:43

根据我对 XP 主题的了解,.msstyles 文件只是具有图像和属性(颜色、大小、字体等)的部件定义的集合,所有这些都是任意定义的。 UxTheme API 仅返回此文件中的任何内容,并且特定属性组合的存在基本上取决于主题作者(这就是为什么您应该始终回退到“经典”GetSysColor,< code>GetSystemMetrics 或 SystemParametersInfo 如果主题 API 无法返回您要查找的内容

但是,您在这里提到了“粉红色主题”,所以我假设您正在谈论 Aero Glass。 Aero 主题颜色由 DWM 处理,并且与经典或 UxTheme API 颜色分开。为了检索 Aero 窗口颜色,您必须使用 DwmGetColorizationColor,这将以 0xAARRGGBB 格式返回。 (与 COLORREF 不同,COLORREF 为 0x00BBGGRR,因此您需要在两种格式之间进行转换)为了首先查找是否启用了 DWM 合成(又名“Aero Glass”),您必须调用DwmIsCompositionEnabled

According to my knowledge of XP themes, an .msstyles file is just a collection of parts definitions that have images and properties (colors, sizes, fonts, etc), all arbitrarily defined. The UxTheme API just returns whatever is in this file, and the presence of a certain combination of properties depends on the theme author, basically (which is why you should always fall back to "classic" GetSysColor, GetSystemMetrics or SystemParametersInfo if the theme API fails to return whatever you are looking for.

However, you mention a "pink theme" here, so I assume you are speaking of an Aero Glass theme. Aero theme colors are handled by the DWM and are yet separate from the classic or UxTheme API colors. In order to retrieve the Aero window color, you must use DwmGetColorizationColor, which will return it in 0xAARRGGBB format (as opposed to a COLORREF which is 0x00BBGGRR, so you will need to translate between the two formats). In order to first find if DWM composition (aka "Aero Glass") is enabled, you must call DwmIsCompositionEnabled.

无声无音无过去 2024-08-20 21:52:43

理解这一点的最简单方法是:实心标题栏的颜色仍然是浅蓝色。

然而,当启用 aero 时,标题栏文本将使用完全透明的背景进行渲染,因此(大部分)是 DWM 为框架着色的任何颜色。

The simplest way to understand this is: The color for solid title bars IS still light blue.

When aero is enabled however, the titlebar text is rendered with a totally transparent background, and thus is (mostly) whatever color the DWM is tinting the frame with.

双手揣兜 2024-08-20 21:52:43

属性常量(即主题函数接受的 iPartId 参数)仅提供主题定义可以(不是必须)为各种类/部件/样式组合定义的一组内容。

即您的代码必须准备好回退到以其他方式确定的颜色。

查看 XP (Luna) 或 Vista/7 (Aero) 上定义的标准主题通常很有用。为此,您可以使用一些工具来做到这一点,例如 ThemeExplorer:
http://sourceforge.net/projects/mctrl/files/theme-explorer/

The property constants (i.e. what the theming functions accept as iPartId parameter) just provide a set of what the theme definitions may (not must) define for various classes/parts/style combinations.

I.e. your code must be ready for fallbacking to a color determined in other way.

It's often useful to see what standard themes on XP (Luna) or Vista/7 (Aero) define. For that you may use some doing that, e.g. ThemeExplorer:
http://sourceforge.net/projects/mctrl/files/theme-explorer/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文