SetSysColors (coredll)
Last changed: JP-212.51.10.12

.
Summary
TODO - a short description

C# Signature:

[DllImport("coredll.dll")]

static extern int SetSysColors(int cElements, Int32[] lpaElements, Int32[] lpaRgbValues);

VB Signature:

<DllImport("Coredll.dll")> _

Public Shared Function SetSysColors(ByVal cElements As Integer, ByRef lpaElements As Integer(), ByRef lpaRgbValues As Integer()) As Integer

End Function

User-Defined Types:

None.

Alternative Managed API:

GetSysColors

Notes:

Windows CE.Net 4.20 not Support.(?)

Always return 1.

Tips & Tricks:

Please add some!

Sample Code:

public class cSystemColors

    {
    /// <summary>
    /// SetSysColors
    /// </summary>
    /// <param name="cElements"></param>
    /// <param name="lpaElements"></param>
    /// <param name="lpaRgbValues"></param>
    /// <returns></returns>

    [DllImport("coredll.dll", SetLastError = true)]
    private static extern bool SetSysColors(int cElements, Int32[] lpaElements, Int32[] lpaRgbValues);

    private const int SYS_COLOR_INDEX_FLAG = 0x40000000;

    public const int COLOR_SCROLLBAR = (0 | SYS_COLOR_INDEX_FLAG);
    public const int COLOR_BACKGROUND = (1 | SYS_COLOR_INDEX_FLAG);
    public const int COLOR_ACTIVECAPTION = (2 | SYS_COLOR_INDEX_FLAG);
    public const int COLOR_INACTIVECAPTION = (3 | SYS_COLOR_INDEX_FLAG);
    public const int COLOR_MENU = (4 | SYS_COLOR_INDEX_FLAG);
    public const int COLOR_WINDOW = (5 | SYS_COLOR_INDEX_FLAG);
    public const int COLOR_WINDOWFRAME = (6 | SYS_COLOR_INDEX_FLAG);
    public const int COLOR_MENUTEXT = (7 | SYS_COLOR_INDEX_FLAG);
    public const int COLOR_WINDOWTEXT = (8 | SYS_COLOR_INDEX_FLAG);
    public const int COLOR_CAPTIONTEXT = (9 | SYS_COLOR_INDEX_FLAG);
    public const int COLOR_ACTIVEBORDER = (10 | SYS_COLOR_INDEX_FLAG);
    public const int COLOR_INACTIVEBORDER = (11 | SYS_COLOR_INDEX_FLAG);
    public const int COLOR_APPWORKSPACE = (12 | SYS_COLOR_INDEX_FLAG);
    public const int COLOR_HIGHLIGHT = (13 | SYS_COLOR_INDEX_FLAG);
    public const int COLOR_HIGHLIGHTTEXT = (14 | SYS_COLOR_INDEX_FLAG);
    public const int COLOR_BTNFACE = (15 | SYS_COLOR_INDEX_FLAG);
    public const int COLOR_BTNSHADOW = (16 | SYS_COLOR_INDEX_FLAG);
    public const int COLOR_GRAYTEXT = (17 | SYS_COLOR_INDEX_FLAG);
    public const int COLOR_BTNTEXT = (18 | SYS_COLOR_INDEX_FLAG);
    public const int COLOR_INACTIVECAPTIONTEXT = (19 | SYS_COLOR_INDEX_FLAG);
    public const int COLOR_BTNHIGHLIGHT = (20 | SYS_COLOR_INDEX_FLAG);
    public const int COLOR_3DDKSHADOW = (21 | SYS_COLOR_INDEX_FLAG);
    public const int COLOR_3DLIGHT = (22 | SYS_COLOR_INDEX_FLAG);
    public const int COLOR_INFOTEXT = (23 | SYS_COLOR_INDEX_FLAG);
    public const int COLOR_INFOBK = (24 | SYS_COLOR_INDEX_FLAG);
    public const int COLOR_STATIC = (25 | SYS_COLOR_INDEX_FLAG);
    public const int COLOR_STATICTEXT = (26 | SYS_COLOR_INDEX_FLAG);
    public const int COLOR_GRADIENTACTIVECAPTION = (27 | SYS_COLOR_INDEX_FLAG);
    public const int COLOR_GRADIENTINACTIVECAPTION = (28 | SYS_COLOR_INDEX_FLAG);

    /// <summary>
    /// SetSystemColor: Methode, die die SetSysColor benutzt um die Systemfarben zu überschreiben
    /// </summary>
    public static void SetSystemColor()
    {

        int[] lpaElements = {
        COLOR_SCROLLBAR,            //COLOR_SCROLLBAR: Color of the gray area of a scroll bar.
        COLOR_BACKGROUND,            //COLOR_BACKGROUND: Background color of the desktop window.
        COLOR_ACTIVECAPTION,        //COLOR_ACTIVECAPTION: Color of the title bar of an active window.
        COLOR_INACTIVECAPTION,        //COLOR_INACTIVECAPTION: Color of the title bar of an inactive window.
        COLOR_MENU,            //COLOR_MENU: Background color of a menu.
        COLOR_WINDOW,            //COLOR_WINDOW: Background color of a window.
        COLOR_WINDOWFRAME,            //COLOR_WINDOWFRAME: Color of a window frame.
        COLOR_MENUTEXT,            //COLOR_MENUTEXT: Color of the text in a menu.
        COLOR_WINDOWTEXT,            //COLOR_WINDOWTEXT: Color of the text in a window.
        COLOR_CAPTIONTEXT,            //COLOR_CAPTIONTEXT: Color of the text in a title bar and of the size box and scroll bar arrow box.
        COLOR_ACTIVEBORDER,        //COLOR_ACTIVEBORDER: Color of the border of an active window.
        COLOR_INACTIVEBORDER,        //COLOR_INACTIVEBORDER: Color of the border of an inactive window.
        COLOR_APPWORKSPACE,        //COLOR_APPWORKSPACE: Background color of multiple document interface (MDI) applications.
        COLOR_HIGHLIGHT,            //COLOR_HIGHLIGHT: Color of an item selected in a control.
        COLOR_HIGHLIGHTTEXT,        //COLOR_HIGHLIGHTTEXT: Color of the text of an item selected in a control.
        COLOR_BTNFACE,            //COLOR_BTNFACE: Color of the face of a button.
        COLOR_BTNSHADOW,            //COLOR_BTNSHADOW: Shadow color of buttons for edges that face away from the light source.
        COLOR_GRAYTEXT,            //COLOR_GRAYTEXT: Color of shaded text.
        COLOR_BTNTEXT,            //COLOR_BTNTEXT: Color of the text for push buttons.
        COLOR_INACTIVECAPTIONTEXT,        //COLOR_INACTIVECAPTIONTEXT: Color of the text in the title bar of an inactive window.
        COLOR_BTNHIGHLIGHT,        //COLOR_BTNHIGHLIGHT: Highlight color of buttons for edges that face the light source.
        COLOR_3DDKSHADOW,            //COLOR_3DDKSHADOW: Color of the dark shadow for three-dimensional display elements.
        COLOR_3DLIGHT,            //COLOR_3DLIGHT: Highlight color of three-dimensional display elements for edges that face the light source.
        COLOR_INFOTEXT,            //COLOR_INFOTEXT: Color of the text for ToolTip controls.
        COLOR_INFOBK,            //COLOR_INFOBK: Background color for ToolTip controls.
        COLOR_STATIC,            //COLOR_STATIC: Background color for static controls and dialog boxes.
        COLOR_STATICTEXT,            //COLOR_STATICTEXT: Color of the text for static controls.
        COLOR_GRADIENTACTIVECAPTION,    //COLOR_GRADIENTACTIVECAPTION: Color of the title bar of an active window that is filled with a color gradient.
        COLOR_GRADIENTINACTIVECAPTION    //COLOR_GRADIENTINACTIVECAPTION: Color of the title bar of an inactive window that is filled with a color gradient.
                };

        int[] lpaRgbValues = {
            Color.Transparent.ToArgb() & 0x00ffffff,     //COLOR_SCROLLBAR: Color of the gray area of a scroll bar.
            Color.Transparent.ToArgb() & 0x00ffffff,     //COLOR_BACKGROUND: Background color of the desktop window.
            Color.Green.ToArgb() & 0x00ffffff,           //COLOR_ACTIVECAPTION: Color of the title bar of an active window.
            Color.Green.ToArgb() & 0x00ffffff,           //COLOR_INACTIVECAPTION: Color of the title bar of an inactive window.
            Color.Green.ToArgb() & 0x00ffffff,           //COLOR_MENU: Background color of a menu.
            Color.Green.ToArgb() & 0x00ffffff,          //COLOR_WINDOW: Background color of a window.
            Color.Green.ToArgb() & 0x00ffffff,             //COLOR_WINDOWFRAME: Color of a window frame.
            Color.Green.ToArgb() & 0x00ffffff,           //COLOR_MENUTEXT: Color of the text in a menu.
            Color.Green.ToArgb() & 0x00ffffff,           //COLOR_WINDOWTEXT: Color of the text in a window.
            Color.Green.ToArgb() & 0x00ffffff,           //COLOR_CAPTIONTEXT: Color of the text in a title bar and of the size box and scroll bar arrow box.
            Color.Green.ToArgb() & 0x00ffffff,             //COLOR_ACTIVEBORDER: Color of the border of an active window.
            Color.Green.ToArgb() & 0x00ffffff,             //COLOR_INACTIVEBORDER: Color of the border of an inactive window.
            Color.Transparent.ToArgb() & 0x00ffffff,     //COLOR_APPWORKSPACE: Background color of multiple document interface (MDI) applications.
            Color.Green.ToArgb() & 0x00ffffff,          //COLOR_HIGHLIGHT: Color of an item selected in a control.
            Color.Green.ToArgb() & 0x00ffffff,           //COLOR_HIGHLIGHTTEXT: Color of the text of an item selected in a control.
            Color.Transparent.ToArgb() & 0x00ffffff,     //COLOR_BTNFACE: Color of the face of a button.
            Color.Transparent.ToArgb() & 0x00ffffff,     //COLOR_BTNSHADOW: Shadow color of buttons for edges that face away from the light source.
            Color.Turquoise.ToArgb() & 0x00ffffff,          //COLOR_GRAYTEXT: Color of shaded text. This color is set to 0 if the current display driver does not support a solid gray color.
            Color.Green.ToArgb() & 0x00ffffff,           //COLOR_BTNTEXT: Color of the text for push buttons.
            Color.Transparent.ToArgb() & 0x00ffffff,     //COLOR_INACTIVECAPTIONTEXT: Color of the text in the title bar of an inactive window.
            Color.Green.() & 0x00ffffff,              //COLOR_BTNHIGHLIGHT: Highlight color of buttons for edges that face the light source.
            Color.Transparent.ToArgb() & 0x00ffffff,     //COLOR_3DDKSHADOW: Color of the dark shadow for three-dimensional display elements.
            Color.Transparent.ToArgb() & 0x00ffffff,     //COLOR_3DLIGHT: Highlight color of three-dimensional display elements for edges that face the light source.
            Color.Transparent.ToArgb() & 0x00ffffff,     //COLOR_INFOTEXT: Color of the text for ToolTip controls.
            Color.Green.ToArgb() & 0x00ffffff,           //COLOR_INFOBK: Background color for ToolTip controls.
            Color.Green.ToArgb() & 0x00ffffff,           //COLOR_STATIC: Background color for static controls and dialog boxes.
            Color.Green.ToArgb() & 0x00ffffff,           //COLOR_STATICTEXT: Color of the text for static controls.
            Color.Transparent.ToArgb() & 0x00ffffff,     //COLOR_GRADIENTACTIVECAPTION: Color of the title bar of an active window that is filled with a color gradient.
            Color.Transparent.ToArgb() & 0x00ffffff      //COLOR_GRADIENTINACTIVECAPTION: Color of the title bar of an inactive window that is filled with a color gradient.
            };

        int iElements = lpaElements.Length;

        bool retVel = cSystemColors.SetSysColors(iElements, lpaElements, lpaRgbValues);
        if (retVel == false)
        {
        int error = Marshal.GetLastWin32Error(); // = 0x80000005 error ?
        throw new Exception(string.Format("SetSysColors() returned {0}!", error));
        }

    }
    }

Documentation