locked
"Window Color and Appearance" Notification Message RRS feed

  • Question

  •  

    Hi,

     

    I want to detect when a user changes the colour scheme in Windows Vista "Window Color and Appearance".

     

    Here's what I've got so far:

     

    Code Block

    // In constructor

    SystemEvents::UserPreferenceChanged += gcnew UserPreferenceChangedEventHandler (this, &Form_Main::SystemEvents_UserPreferenceChanged);

     

    // In destructor

    SystemEvents::UserPreferenceChanged -= gcnew UserPreferenceChangedEventHandler (this, &Form_Main::SystemEvents_UserPreferenceChanged);

     

    void SystemEvents_UserPreferenceChanged (Object ^sender, UserPreferenceChangedEventArgs ^e)

    {

    MessageBox::Show ("SystemEvents_UserPreferenceChanged.\n" + e->ToString ());

    // Change ToolStripManager::Renderer and ColorTable

    }

     

     

     

     

    When I change between Default, Graphite and Blue, etc, in "Window Color and Appearance", the above code is NOT called. If I open the classic appearance properties and apply changes, the above code IS called. I've also tried UserPreferenceChanging, PaletteChanged, DisplaySettingsChanged and SystemColorsChanged. What have I missed? Any ideas?

     

    Thanks.

    Wednesday, January 2, 2008 6:16 AM

Answers

  • I think I've got it sorted now:

    Code Block

     

    protected:

    virtual void WndProc (Message %m) override

    {

    Trace::WriteLine (m.ToString ());

    Form::WndProc (m);

    const int WM_DWMCOLORIZATIONCOLORCHANGED = 0x0320;

    if (m.Msg == WM_DWMCOLORIZATIONCOLORCHANGED)

    {

    MessageBox::Show ("WM_DWMCOLORIZATIONCOLORCHANGED");

    // Change ToolStripManager::Renderer and ColorTable

    }

    }

     

     

    Though this event only fires on a committal.

     

    It would be good if MS implemented WM_DWMCOLORIZATIONCOLORCHANGING.

    Wednesday, January 2, 2008 7:32 AM
  • Here's a useful addition to get the colour at application start-up:

     

    Code Block

    // In Constructor

    int i_colour = 0;

    int i_opaque = false;

    int hr = DwmApi::DwmGetColorizationColor (&i_colour, &i_opaque);

    if (hr >= 0)

    {

    // Set ToolStripManager::Renderer and ColorTable

    }

     

     

     

     

    Code Block

    // Add a new class

    using namespace System::Runtime::InteropServices;

    value class DwmApi

    {

    public:

    [DllImport ("dwmapi.dll")]

    static int DwmGetColorizationColor (int*, int*);

    };

     

     

     

    Wednesday, January 2, 2008 4:11 PM

All replies

  • I think I've got it sorted now:

    Code Block

     

    protected:

    virtual void WndProc (Message %m) override

    {

    Trace::WriteLine (m.ToString ());

    Form::WndProc (m);

    const int WM_DWMCOLORIZATIONCOLORCHANGED = 0x0320;

    if (m.Msg == WM_DWMCOLORIZATIONCOLORCHANGED)

    {

    MessageBox::Show ("WM_DWMCOLORIZATIONCOLORCHANGED");

    // Change ToolStripManager::Renderer and ColorTable

    }

    }

     

     

    Though this event only fires on a committal.

     

    It would be good if MS implemented WM_DWMCOLORIZATIONCOLORCHANGING.

    Wednesday, January 2, 2008 7:32 AM
  • Here's a useful addition to get the colour at application start-up:

     

    Code Block

    // In Constructor

    int i_colour = 0;

    int i_opaque = false;

    int hr = DwmApi::DwmGetColorizationColor (&i_colour, &i_opaque);

    if (hr >= 0)

    {

    // Set ToolStripManager::Renderer and ColorTable

    }

     

     

     

     

    Code Block

    // Add a new class

    using namespace System::Runtime::InteropServices;

    value class DwmApi

    {

    public:

    [DllImport ("dwmapi.dll")]

    static int DwmGetColorizationColor (int*, int*);

    };

     

     

     

    Wednesday, January 2, 2008 4:11 PM