CBrush::operator HBRUSH

Use this operator to get the attached Windows GDI handle of the CBrush object.

operator HBRUSH( ) const;

Return Value

If successful, a handle to the Windows GDI object represented by the CBrush object; otherwise NULL.

Remarks

This operator is a casting operator, which supports direct use of an HBRUSH object.

For more information about using graphic objects, see Graphic Objects in the Windows SDK.

Example

RECT rc = { 50, 50, 200, 200 };

Rectangle(pDC->GetSafeHdc(), rc.left, rc.top, rc.right, rc.bottom);

// The Win32 call to FillRect requires an HBRUSH.
// The HBRUSH operator casts the CBrush object
// to the required type.
CBrush brush;
brush.CreateSysColorBrush(COLOR_BTNFACE);
FillRect(pDC->GetSafeHdc(), &rc, (HBRUSH)brush);

Requirements

Header: afxwin.h

See Also

Concepts

CBrush Class

CBrush Members

Hierarchy Chart