Getting the color value of TaskDialog Main Instruction text
Asked Answered
B

2

8

The TaskDialog in Windows7 has a blue Main Instruction text at the top. Is there a way to get that color as a Brush value in WPF?

Breathtaking answered 15/5, 2011 at 17:22 Comment(5)
How about cutting edge tech like the eyedropper in mspaint?Rochellerochemont
@H.B. That will usually give you the wrong value due to antialiasing and blending.Unmitigated
@Unmitigated Einstein: The font is rather big though, it might be possible to find a solid pixel in it.Rochellerochemont
@H.B. that will only give you a rough estimate on the colour on your current system. It will completely break with other theme colours, high contrast themes etc. Do not hardcode colours but try to get them from the framework/OS whenever possible.Dealings
@Rochellerochemont Hardcoding the text color will fall over dead when the Windows color scheme changes. Rather than follow your suggestion, we want to be good developers.Okwu
U
9

These colors are actually defined in the Windows User Experience Interaction Guidelines. As far as I know they are not available as named system colors, but the guide explicitly lists the RGB colors and font sizes for the various text elements.

Unmitigated answered 15/5, 2011 at 17:53 Comment(0)
A
2

I've written about this here: http://blog.quppa.net/2011/04/30/windows-theme-fonts/

In short, no, there is no support in WPF for retrieving the font size/colour/etc. of theme parts, but there is in Win32 with the GetThemeFont and GetThemeColor functions. These will only work when visual styles are enabled, however, and you will need to hard-code fallback values when Windows Classic or the High-Contrast themes are in use. In the case of 'Main Instruction' text, you should use the caption font (mercifully this is accessible through WPF).

Adaurd answered 4/6, 2011 at 16:35 Comment(1)
I've posted some sample WPF code here: blog.quppa.net/2011/10/24/windows-theme-fonts-redux-sample-codeAdaurd

© 2022 - 2024 — McMap. All rights reserved.