一、获取系统画刷
1.Win32
HGDIOBJ GetStockObject(
int fnObject // stock object type
);
系统画刷类型如下:
BLACK_BRUSH
WHITE_BRUSH
GRAY_BRUSH
DKGRAY_BRUSH
LTGRAY_BRUSH
DC_BRUSH
HOLLOW_BRUSH
NULL_BRUSH
示例:
HBRUSH hBlackBrush = (HBRUSH)::GetStockObject(BLACK_BRUSH);
2.MFC
示例:
HBRUSH hBlackBrush = (HBRUSH)::GetStockObject(BLACK_BRUSH);
CBrush brush;
brush.Attach(hBlackBrush);
或
HBRUSH hBlackBrush = (HBRUSH)::GetStockObject(BLACK_BRUSH);
CBrush* pBrush = CBrush::FromHandle(hBlackBrush);
二、创建指定颜色的逻辑画刷
1.Win32
HBRUSH CreateSolidBrush(
COLORREF crColor // brush color value
);
2.MFC
BOOL CBrush::CreateSolidBrush(
COLORREF crColor
);
三、获取系统颜色画刷
1.Win32
HBRUSH GetSysColorBrush(
int nIndex // system color index
);
常用的系统颜色索引为:
COLOR_BTNTEXT
COLOR_CAPTIONTEXT
COLOR_GRAYTEXT
COLOR_HIGHLIGHT
COLOR_HIGHLIGHTTEXT
2.MFC
BOOL CBrush::CreateSysColorBrush(
int nIndex // system color index
);