[DllImport("uxtheme", EntryPoint = "#122")]
static extern int SetUserColorPreference(ref IMMERSIVE_COLOR_PREFERENCE pcpPreference, bool fForceSetting);
Declare Function SetUserColorPreference Lib "uxtheme.dll" (TODO) As TODO
[StructLayout(LayoutKind.Sequential)]
private struct IMMERSIVE_COLOR_PREFERENCE
{
public uint dwColorSetIndex;
public uint crStartColor;
public uint crAccentColor;
}
None for now
//To convert Colors from their UINT form to the managed Color class and vice versa:
private static uint ToUint(Color c)
{
return (uint)((c.B << 16) | (c.G << 8) | c.R);
}
private static Color ToColor(uint c)
{
int R = (int)(c & 0xFF) % 256;
int G = (int)((c >> 8) & 0xFFFF) % 256;
int B = (int)(c >> 16) % 256;
return Color.FromArgb(R, G, B);
}
[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);
}