0

On Vista, with Aero enabled, the window's title in normal mode has text in black (written over a slightly light glass) while when maximized the title is in white (written over a dark glass).

How can I determine the current color of the window title ?

P.S. I wrote a program to watch after SystemColors.ActiveCaptionTextColor, but it remains the same in two modes.

bohdan_trotsenko
  • 5,167
  • 3
  • 43
  • 70

4 Answers4

1

The system color doesn't actually change. What you're seeing is the application of the Aero theme to the window. There are themeing APIs available to grab the theme specific colors but my experience has been less than stellar using them.

UPDATE FROM COMMENTS: Take a look at the VisualStyleRenderer and the GetColor method.

Paul Alexander
  • 31,970
  • 14
  • 96
  • 151
  • I apply glass effect to all the window. It displays a pie chart and some statistics, glass effect makes the window look cool and beautiful ... until it is maximized. The idea is to bind the foreground color of the text to the current color of the caption, which is kept coherent to glass effect. – bohdan_trotsenko Jun 24 '09 at 07:54
  • The VisualStyleRenderer should help with that. – Paul Alexander Jun 24 '09 at 08:16
  • Please help me find which one exactly. Either I miss the obvious, or look in a wrong place, or ... – bohdan_trotsenko Jun 29 '09 at 10:25
1

i can't make VisualStyleRenderer tell me anything either.

You can choose between:

Because MaxCaption provides VisualStyleElement objects for each state of the title bar of a maximized window.

Except it doesn't actually work. If you ask for the caption text color of an active maximized window:

VisualStyleRenderer renderer = 
   new VisualStyleRenderer(VisualStyleElement.Window.MaxCaption.Active);
Color c = renderer.GetColor(ColorProperty.TextColor);

It returns black, for both Caption and MaxCaption.

In fact, almost all colors are the same between the two:

alt text

My guess is that there's no way to make your application have the same look and feel as the operating system.

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
Ian Boyd
  • 246,734
  • 253
  • 869
  • 1,219
0

why don't you try to listen for SystemColorsChanged event in your form?

    SystemColorsChanged += new EventHandler(Form1_SystemColorsChanged);

    void Form1_SystemColorsChanged(object sender, EventArgs e)
    {
        //try repainting or refreshing your application
    }

I know this is not be the exact solution but you may start working from here.

TheVillageIdiot
  • 40,053
  • 20
  • 133
  • 188
0

Regarding the VisualStyleRenderer based suggestions it might be worth noting, that apparently maximized window captions are handled specially by the Vista DWM (Desktop Window Manager) for performance reasons, see Raymond Chen's explanation for (some) details.

Now, I haven't peeked into the Aero theme itself but it might actually define the same TextColor for both the normal and the maximized caption, the latter just not being used by the DWM.

That said I would have guessed that the captions text color in Vista is indeed determined by VisualStyleElement.Window.Caption.Active for themed normal windows but the former SystemColors.ActiveCaptionTextColor for maximized windows only; unfortunately you figured out already that this is not the case either.

So maybe the DWM just applies an internal default while rendering maximized window captions? If this would be the case you couldn't detect the caption text color change 'by design', rather would need to resort on observing the maximized window state as such and apply the DWM default locally.

Steffen Opel
  • 63,899
  • 11
  • 192
  • 211