CBrush

Win32++

CBrush Class

Description

The class responsible for creating and managing brush resources.

CBrush Members

Initialization and Assignment
CBrush
CBrush();
CBrush(HBRUSH hBrush);
CBrush(COLORREF crColor);
Constructs a CBrush object.
FromHandle
static CBrush* FromHandle(HBRUSH hBrush);
Returns the CBrush associated with the specified brush handle. If a CBrush object doesn't already exist, a temporary CBrush object is created. This temporary CBrush will be deleted sometime after the processing of the current message is complete. operator HBRUSH()
operator HBRUSH() const;
Allows a CBrush object to be used as a brush handle (HBRUSH).   Attributes GetLogBrush
LOGBRUSH GetLogBrush() const;
Retrieves the LOGBRUSH structure that defines the style, color, and pattern of a physical brush.   Operations CreateBrushIndirect
HBRUSH CreateBrushIndirect(LPLOGBRUSH lpLogBrush);
Creates a logical brush from style, color, and pattern specified in the LOGPRUSH struct. CreateDIBPatternBrush
HBRUSH CreateDIBPatternBrush(HGLOBAL hglbDIBPacked, UINT fuColorSpec);
Creates a logical brush that has the pattern specified by the device-independent bitmap (DIB). CreateDIBPatternBrushPt
HBRUSH CreateDIBPatternBrushPt(LPCVOID lpPackedDIB, UINT nUsage);
Creates a logical brush that has the pattern specified by the device-independent bitmap (DIB). CreateHatchBrush
HBRUSH CreateHatchBrush(int nIndex, COLORREF crColor);
Creates a logical brush that has the specified hatch pattern and color. CreatePatternBrush
HBRUSH CreatePatternBrush(CBitmap* pBitmap);
Creates a logical brush with the specified bitmap pattern. The bitmap can be a DIB section bitmap, which is created by the CreateDIBSection function, or it can be a device-dependent bitmap. CreateSolidBrush
HBRUSH CreateSolidBrush(COLORREF crColor);
Creates a logical brush that has the specified solid color. 
Base class Members

For base class members, refer to the members of CGDIObject.

Remarks

CBrush objects can be used anywhere a a handle to a brush (HBRUSH) might be used.  They can be substituted for the HBRUSH in any of the Windows API functions which use a HBRUSH as a function argument.  The benefit of using a CBrush object is that it automatically deletes the brush when it is destroyed.

Refer to the Graphics Device Interface section of Using Win32++ for additional information on using this class.

Summary Information

Header file gdi.h
Win32/64 support Yes
WinCE support Yes