5

This is a follow-up to my earlier question Draw Custom Buttons on Windows Vista/7 Aero Titlebar.

I revisited the topic quite recently and found this article which is essentially a hack to 'drawing' buttons on Aero-enabled title bar (Windows Vista & 7). What the code does is to create a transparent window over the current one and places the buttons on it, giving the impression of additional buttons on the title bar. The only problem is the buttons look like regular WinForms buttons!

My question is, how do I read the windows shell style (aka theme) in order to create buttons styled just like those in the Control Box (see image)?

I'd like answers to be in .NET (VB.NET or C#). I'm okay with unmanaged code.

Control Buttons

Community
  • 1
  • 1
Alex Essilfie
  • 12,339
  • 9
  • 70
  • 108

1 Answers1

1

So if I understand you correctly, you want to read what Windows 7 calls the "Window Color" aspect of the current theme.

Acording to MSDN http://msdn.microsoft.com/en-us/magazine/cc163435.aspx, you want DwmGetColorizationColor: "retrieves the current color that is being used for DWM glass composition. This value is based on the current color scheme. Changing the setting causes a WM_WMCOLORIZATIONCOLORCHANGED notification."

[DllImport("dwmapi.dll", PreserveSig = false)]
public static extern void DwmGetColorizationColor(out int pcrColorization, [MarshalAs(UnmanagedType.Bool)]out bool pfOpaqueBlend);

"You can check to see the composition color and opacity by calling the DwmGetColorizationColor function. If this function succeeds, it will set a GDI+ ARGB color value and a Boolean indicating whether the color is opaque. Just like changing the Aero scheme in the control panel, there's a message broadcast when the composition color has changed. WM_DWMCOLORIZATIONCOLORCHANGED is sent when this happens, but in this case the parameters tell you what the new color and opacity are."

Josh
  • 903
  • 8
  • 15
  • Thanks for your response. It made a good read though it wasn't what I really wanted. What I'd like to do is to create a button similar to those go the control box (max, min & close). – Alex Essilfie Dec 02 '11 at 10:16
  • There might not be an API for that: that's why I figured you might have to read the Window Color and then draw the button using the Window Color as a hint. Can you think of any other applications that do what you're trying to do? – Josh Dec 02 '11 at 10:18
  • Yeah. See the screenshots I added in the first question (http://stackoverflow.com/questions/4117874/draw-custom-buttons-on-windows-vista-7-aero-titlebar). DisplayFusion, a multiple desktop manager is able to do that, with glow effect all. – Alex Essilfie Dec 02 '11 at 10:30