How do I get the text color for the taskbar clock?

Q

Quoner

With XP's default theme (Windows XP style / Default (blue) on the Display
Properties/Appearance tab), the taskbar clock foreground color is white.
Change that to Windows XP style / Olive Green, and that taskbar clock
foreground changes to black.

So my question is, how do I get that color programmatically?

Thanks!
 
D

Dmitriy Lapshin [C# / .NET MVP]

Hi,

Do you have any information that this color is at all stored anywhere? I
just think the system might check whether the taskbar background is light or
dark and choose the appropriate clock foreground color.
 
Q

Quoner

Hmm....that's an interesting point. But then, how does one determine the
taskbar background color?

Thanks.

Dmitriy Lapshin said:
Hi,

Do you have any information that this color is at all stored anywhere? I
just think the system might check whether the taskbar background is light
or dark and choose the appropriate clock foreground color.

--
Sincerely,
Dmitriy Lapshin [C# / .NET MVP]
Bring the power of unit testing to the VS .NET IDE today!
http://www.x-unity.net/teststudio.aspx

Quoner said:
With XP's default theme (Windows XP style / Default (blue) on the Display
Properties/Appearance tab), the taskbar clock foreground color is white.
Change that to Windows XP style / Olive Green, and that taskbar clock
foreground changes to black.

So my question is, how do I get that color programmatically?

Thanks!
 
M

Mattias Sjögren

So my question is, how do I get that color programmatically?

I think you can use OpenThemeData("Clock") followed by
GetThemeColor(CLP_TIME, TMT_TEXTCOLOR). The taskbar clock itself
simply uses The DrawThemeText API. If Visual Styles are disables, you
can fall back on the button text color.


http://msdn.microsoft.com/library/en-us/shellcc/platform/commctls/userex/functions/openthemedata.asp
http://msdn.microsoft.com/library/en-us/shellcc/platform/commctls/userex/functions/getthemecolor.asp



Mattias
 
Q

Quoner

Thanks for the reply.

Sorry to be such a newbie, but these are the calls I'm now trying:

HTHEME hTheme = OpenThemeData(HWND_DESKTOP, L"Clock");
GetThemeColor(hTheme, CLP_TIME, CLS_NORMAL, TMT_TEXTCOLOR, &color);

But that first call returns NULL for the hTheme. The same call works for,
say, L"Button", but not for L"Clock". Is that first parameter, HWND_DESKTOP,
incorrect, and if so, what is the correct parameter?

Thanks again.
 
M

Mattias Sjögren

Is that first parameter, HWND_DESKTOP,
incorrect, and if so, what is the correct parameter?

Don't you have your own window handle you can pass in? HWND_DESKTOP is
a pseudo handle for use with the MapWindowPoints function.



Mattias
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top