Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Download Visual Studio Add-In

SetUserColorPreference (uxtheme)
 
.
Summary
SetUserColorPreference will set the current theme Accent color and the Start menu color through uint numbers representing colors inside the IMMERSIVE_COLOR_PREFERENCE structure

C# Signature:

[DllImport("uxtheme", EntryPoint = "#122")]
static extern int SetUserColorPreference(ref IMMERSIVE_COLOR_PREFERENCE pcpPreference, bool fForceSetting);

VB Signature:

Declare Function SetUserColorPreference Lib "uxtheme.dll" (TODO) As TODO

User-Defined Types:

[StructLayout(LayoutKind.Sequential)]

  private struct IMMERSIVE_COLOR_PREFERENCE
  {
     public uint dwColorSetIndex;
     public uint crStartColor;
     public uint crAccentColor;
  }

Notes:

None for now

Tips & Tricks:

Please add some!

Sample Code:

[DllImport("uxtheme", EntryPoint = "#122")]
static extern int SetUserColorPreference(ref IMMERSIVE_COLOR_PREFERENCE pcpPreference, bool fForceSetting);

private static uint ToUint(Color c)
{
     return (uint)((c.B << 16) | (c.G << 8) | c.R);
}

[StructLayout(LayoutKind.Sequential)]
  private struct IMMERSIVE_COLOR_PREFERENCE
  {
     public uint dwColorSetIndex;
     public uint crStartColor;
     public uint crAccentColor;
  }

private void SetAccentColor(Color c)

    {
        IMMERSIVE_COLOR_PREFERENCE temp = new IMMERSIVE_COLOR_PREFERENCE
        {
        crAccentColor = ToUint(c),
        dwColorSetIndex = 0,
        crStartColor = ToUint(c)
        };
        SetUserColorPreference(ref temp, true);
    }

Documentation

Please edit this page!

Do you have...

  • helpful tips or sample code to share for using this API in managed code?
  • corrections to the existing content?
  • variations of the signature you want to share?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).

 
Access PInvoke.net directly from VS:
Terms of Use
Find References
Show Printable Version
Revisions