开发者

Is there a list of valid parameter combinations for GetThemeColor / Visual Styles API

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".


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.


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.


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/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜