Export (0) Print
Expand All

GetSysColorBrush function

The GetSysColorBrush function retrieves a handle identifying a logical brush that corresponds to the specified color index.

Syntax


HBRUSH GetSysColorBrush(
  _In_  int nIndex
);

Parameters

nIndex [in]

A color index. This value corresponds to the color used to paint one of the window elements. See GetSysColor for system color index values.

Return value

The return value identifies a logical brush if the nIndex parameter is supported by the current platform. Otherwise, it returns NULL.

Remarks

A brush is a bitmap that the system uses to paint the interiors of filled shapes. An application can retrieve the current system colors by calling the GetSysColor function. An application can set the current system colors by calling the SetSysColors function.

An application must not register a window class for a window using a system brush. To register a window class with a system color, see the documentation of the hbrBackground member of the WNDCLASS or WNDCLASSEX structures.

System color brushes track changes in system colors. In other words, when the user changes a system color, the associated system color brush automatically changes to the new color.

To paint with a system color brush, an application should use GetSysColorBrush (nIndex) instead of CreateSolidBrush ( GetSysColor (nIndex)), because GetSysColorBrush returns a cached brush instead of allocating a new one.

System color brushes are owned by the system so you don't need to destroy them. Although you don't need to delete the logical brush that GetSysColorBrush returns, no harm occurs by calling DeleteObject.

Requirements

Minimum supported client

Windows 2000 Professional [desktop apps only]

Minimum supported server

Windows 2000 Server [desktop apps only]

Header

Winuser.h (include Windows.h)

Library

User32.lib

DLL

User32.dll

See also

Brushes Overview
Brush Functions
CreateSolidBrush
GetSysColor
SetSysColors
WNDCLASS
WNDCLASSEX

 

 

Community Additions

ADD
Show:
© 2014 Microsoft