I am trying to make application that has color theme of users windows theme (Form Background, text color etc..)
Is it possible to get #color that the user has selected in their Win 8.1/10?
I am talking about this specific setting:
I am trying to make application that has color theme of users windows theme (Form Background, text color etc..)
Is it possible to get #color that the user has selected in their Win 8.1/10?
I am talking about this specific setting:
This is an example i have created, also based on the link that Hans Passant posted above. Another similar approach can be found on GitHub see AccentColorService
public class ThemeInfo
{
[DllImport("uxtheme.dll", EntryPoint = "#95")]
public static extern uint GetImmersiveColorFromColorSetEx(uint dwImmersiveColorSet, uint dwImmersiveColorType, bool bIgnoreHighContrast, uint dwHighContrastCacheMode);
[DllImport("uxtheme.dll", EntryPoint = "#96")]
public static extern uint GetImmersiveColorTypeFromName(IntPtr pName);
[DllImport("uxtheme.dll", EntryPoint = "#98")]
public static extern int GetImmersiveUserColorSetPreference(bool bForceCheckRegistry, bool bSkipCheckOnFail);
public Color GetThemeColor()
{
var colorSetEx = GetImmersiveColorFromColorSetEx(
(uint)GetImmersiveUserColorSetPreference(false, false),
GetImmersiveColorTypeFromName(Marshal.StringToHGlobalUni("ImmersiveStartSelectionBackground")),
false, 0);
var colour = Color.FromArgb((byte)((0xFF000000 & colorSetEx) >> 24), (byte)(0x000000FF & colorSetEx),
(byte)((0x0000FF00 & colorSetEx) >> 8), (byte)((0x00FF0000 & colorSetEx) >> 16));
return colour;
}
}