SetSysColors

2.x

  void SetSysColors(cDspElements, lpnDspElements, lpdwRgbValues)    
  int cDspElements; /* number of elements to change */
  const int FAR* lpnDspElements; /* address of array of elements */
  const COLORREF FAR* lpdwRgbValues; /* address of array of RGB values */

The SetSysColors function sets the system colors for one or more display elements. Display elements are the various parts of a window and the Windows background that appear on the screen.

The SetSysColors function sends a WM_SYSCOLORCHANGE message to all windows to inform them of the change in color. It also directs Windows to repaint the affected portions of all currently visible windows.

Parameters

cDspElements

Specifies the number of display elements in the array pointed to by the lpnDspElements parameter.

lpnDspElements

Points to an array of integers that specify the display elements to be changed. For a list of possible display elements, see the following Comments section.

lpdwRgbValues

Points to an array of unsigned long integers that contains the new RGB (red-green-blue) color value for each display element in the array pointed to by the lpnDspElements parameter.

Return Value

This function does not return a value.

Comments

The SetSysColors function changes the current Windows session only. The new colors are not saved when Windows terminates.

Following are the display elements that may be used in the lpnDspElements array:

Value Meaning

COLOR_ACTIVEBORDER Active window border.
COLOR_ACTIVECAPTION Active window title.
COLOR_APPWORKSPACE Background color of multiple document interface (MDI) applications.
COLOR_BACKGROUND Desktop.
COLOR_BTNFACE Face shading on push buttons.
COLOR_BTNHIGHLIGHT Selected button in a control.
COLOR_BTNSHADOW Edge shading on push buttons.
COLOR_BTNTEXT Text on push buttons.
COLOR_CAPTIONTEXT Text in title bar, size button, scroll-bar arrow button.
COLOR_GRAYTEXT Grayed (dimmed) text. This color is zero if the current display driver does not support a solid gray color.
COLOR_HIGHLIGHT Background of selected item in a control.
COLOR_HIGHLIGHTTEXT Text of selected item in a control.
COLOR_INACTIVEBORDER Inactive window border.
COLOR_INACTIVECAPTION Inactive window title.
COLOR_INACTIVECAPTIONTEXT Color of text in an inactive title.
COLOR_MENU Menu background.
COLOR_MENUTEXT Text in menus.
COLOR_SCROLLBAR Scroll-bar gray area.
COLOR_WINDOW Window background.
COLOR_WINDOWFRAME Window frame.
COLOR_WINDOWTEXT Text in windows.

Example

The following example changes the window background to black and the text in the window to green:

int aiDspElements[2];
DWORD aRgbValues[2];

aiDspElements[0] = COLOR_WINDOW;
aRgbValues[0] = RGB(
    0x00,   /* red   */
    0x00,   /* green */
    0x00);  /* blue  */
aiDspElements[1] = COLOR_WINDOWTEXT;
aRgbValues[1] = RGB(
    0x00,   /* red   */
    0xff,   /* green */
    0x00);  /* blue  */
SetSysColors(2, aiDspElements, aRgbValues);

See Also

GetSysColor