locked
Modify Aero Glass Color RRS feed

  • Question

  • Hi,

    I have searched for serveral days, readed the platform dsk and header files, used the dependency walker... But I can't figure out how it is possible to change the color for aero glass (which is blue by default).

    I want to change it to yellow (or brown) if the battery level (only for laptops of course) is low, to red when its critical. I have read a lot and was able to read the color (registry and api) and I was able to get notified when the color changes (wndproc) but there is no api call to set the color. I am able to set the registry key. That works, but requires a reboot, which is (in my case) not a solution. I have tried to simulate the wndproc message as broadcast, no result...

    What does the control panel applet do? If I change the color there it will be instantly applied, even the setting is not saved to the registry (which will be the best solution for my case).

    Programming language is vb9, vista is required by the application itself, so no other checks are required.

    Thanks again for your help
    Monday, January 12, 2009 10:28 PM

Answers

  • There's an undocumented function I found here. DwmpSetColorization. I guess the p is a typo.

    Imports System.Runtime.InteropServices 
     
    Public Class Form1 
     
        <DllImport("dwmapi.dll", EntryPoint:="#104", CallingConvention:=CallingConvention.Winapi)> _ 
        Public Shared Function DwmSetColorization(ByVal ColorizationColor As UInteger, ByVal ColorizationOpaqueBlend As BooleanByVal Opacity As UInteger) As Integer 
        End Function 
     
        Private WithEvents t As New Timer 
        Private rand As New Random 
     
        Private Sub Form1_Load(ByVal sender As System.ObjectByVal e As System.EventArgs) Handles MyBase.Load 
            t.Interval = 50 
            t.Start() 
        End Sub 
     
        Private Sub t_Tick(ByVal sender As ObjectByVal e As System.EventArgs) Handles t.Tick 
            Dim color(3) As Byte 
            rand.NextBytes(color) 
            DwmSetColorization(BitConverter.ToUInt32(color, 0), False, 0UI) 
        End Sub 
     
    End Class 


    You'll have to play with it to see how it works. The code example in the page I linked to is for battery charge.

    As it's undocumented it could disappear one day leaving you with a broken app.

    Mine's now set to bile green and I feel sick. Typical that it chose something so horrible.


    • Marked as answer by TommyB83 Tuesday, January 13, 2009 10:48 PM
    Monday, January 12, 2009 10:59 PM

All replies

  • I'm not a great expert on the new dwm api's - but...   I know that if a color is changed, then a WM_WMCOLORIZATIONCOLORCHANGED message is sent.   The problem is you probably don't want to have this sent to every app...  But, I'd be willing to bet if you looked up the parameter info to this message, and then sent it to your own window (using SendMessage, and not broadcast it) then your frame would change color...  Maybe I'll try this out latter when I have access to my Vista machine :)

    HTH
    Tom Shelton
    Monday, January 12, 2009 10:59 PM
  • There's an undocumented function I found here. DwmpSetColorization. I guess the p is a typo.

    Imports System.Runtime.InteropServices 
     
    Public Class Form1 
     
        <DllImport("dwmapi.dll", EntryPoint:="#104", CallingConvention:=CallingConvention.Winapi)> _ 
        Public Shared Function DwmSetColorization(ByVal ColorizationColor As UInteger, ByVal ColorizationOpaqueBlend As BooleanByVal Opacity As UInteger) As Integer 
        End Function 
     
        Private WithEvents t As New Timer 
        Private rand As New Random 
     
        Private Sub Form1_Load(ByVal sender As System.ObjectByVal e As System.EventArgs) Handles MyBase.Load 
            t.Interval = 50 
            t.Start() 
        End Sub 
     
        Private Sub t_Tick(ByVal sender As ObjectByVal e As System.EventArgs) Handles t.Tick 
            Dim color(3) As Byte 
            rand.NextBytes(color) 
            DwmSetColorization(BitConverter.ToUInt32(color, 0), False, 0UI) 
        End Sub 
     
    End Class 


    You'll have to play with it to see how it works. The code example in the page I linked to is for battery charge.

    As it's undocumented it could disappear one day leaving you with a broken app.

    Mine's now set to bile green and I feel sick. Typical that it chose something so horrible.


    • Marked as answer by TommyB83 Tuesday, January 13, 2009 10:48 PM
    Monday, January 12, 2009 10:59 PM
  • If this work you are my hero!
    This is exactly what I have searched for my BattCursor project :)

    I cant read the link you have provided (neither english or german) but I will try this tomorrow and report if it was successfully or not.

    Already many thanks for this very fast reply :)

    ( edit, btw: I have to change it for any window, not only my own. This is because my application has no visible window, except the configuration dialog, so if the postmessage would work I will have to use broadcast ;) )
    Monday, January 12, 2009 11:11 PM
  • I can just about get by in French, but I understood the C# well enough.
    It changes all windows. This is pretty intrusive on the user who won't want their whole color theme changed. The sample code sets it back when the application exits.
    Monday, January 12, 2009 11:23 PM
  • Finally you are my hero ^^
    Works perfectly, exact what I have searched for!

    Many, many thanks!
    Tuesday, January 13, 2009 10:49 PM
  • Sad but true this will not work for Windows 7 (RC1).
    Any ideas?

    Tuesday, May 19, 2009 11:38 AM
  • It's not the true way!

    It doesn't work for Windows 7!

    You should use this:

        ''' <summary>
        ''' Gets Is current OS Windows Vista or later?
        ''' </summary>
        Public Shared ReadOnly Property AeroSupport As Boolean
            Get
                Return Environment.OSVersion.Version.Major >= 6
            End Get
        End Property
      ''' <summary>
        ''' Gets or sets current Aero Color.
        ''' </summary>
        <Description("Current Aero Color."), Category("Aero")>
        Public Shared Property AeroColor As Color
            Get
                If AeroSupport = False Then
                    Return Color.Transparent
                End If
                Dim AARRGGBB = My.Computer.Registry.GetValue("HKEY_CURRENT_USER\Software\Microsoft\Windows\DWM""ColorizationColor""00000000")
                Dim Argb As Integer = Convert.ToInt32(CLng(AARRGGBB.ToString), 10)
                Return System.Drawing.Color.FromArgb(Argb)
            End Get
            Set(ByVal value As Color)
                If AeroSupport = False Then
                    Exit Property
                End If
                Dim Color(3) As Byte
                Color(0) = value.B
                Color(1) = value.G
                Color(2) = value.R
                Color(3) = value.A
                Dim p As WDM_COLORIZATION_PARAMS
                DwmGetColorizationParameters(p)
                If IntensityForAeroColor <> -1 Then
                    p.Intensity = IntensityForAeroColor
                End If
                p.Color1 = BitConverter.ToUInt32(Color, 0)
                DwmSetColorizationParameters(p, True)
                My.Computer.Registry.SetValue("HKEY_CURRENT_USER\Software\Microsoft\Windows\DWM""ColorizationColor", value.ToArgb, Microsoft.Win32.RegistryValueKind.DWord)
            End Set
     <DllImport("dwmapi.dll", EntryPoint:="#127", PreserveSig:=False)> _
    Public Shared Sub DwmGetColorizationParameters(ByRef parameters As WDM_COLORIZATION_PARAMS)
    End Sub

    <DllImport("dwmapi.dll", EntryPoint:="#131", PreserveSig:=False)> _
    Public Shared Sub DwmSetColorizationParameters(ByRef parameters As WDM_COLORIZATION_PARAMS, ByVal uUnknown As UInteger)
    End Sub
     Public Structure WDM_COLORIZATION_PARAMS
    Public Color1 As UInteger
    Public Color2 As UInteger
    Public Intensity As UInteger
    Public Unknown1 As UInteger
    Public Unknown2 As UInteger
    Public Unknown3 As UInteger
    Public Opaque As UInteger
    End Structure
    It also works with Vista!
    Friday, March 4, 2011 4:38 AM
  • Sad but true this will not work for Windows 7 (RC1).
    Any ideas?


    I post a solution here.
    Friday, March 4, 2011 4:39 AM