Introduction
This article shows how to use a pattern brush to give your application a similar look and feel, and it also includes a pattern brush bits tool, with this tool you can create a new style of pattern brush very quickly.
How to use it
The steps for usage are as follows:
- Run application brushtool.exe.
- Click on the left design panel to draw a style, you can click >> button to preview the style.
- Click copy button to copy the bits to clipboard.
- Call the following code to use the pattern brush. (You can paste the brush bits to the red field)
Code
WORD m_bitsBrush1[8] = { 0xee,0xed,0xeb,0xe7,0xef,0xff,0xff,0xff };
CBrush brush,*pOldbrush;
CBitmap bm;
bm.CreateBitmap(8,8,1,1,m_bitsBrush1);
LOGBRUSH logBrush;
logBrush.lbStyle = BS_PATTERN;
logBrush.lbHatch = (int) bm.GetSafeHandle();
logBrush.lbColor = RGB(0,0,0);
brush.CreateBrushIndirect(&logBrush);
int savedc = dc.SaveDC();
pOldbrush=dc.SelectObject(&brush);
dc.SetBkMode(TRANSPARENT);
dc.SetBkColor(RGB(255,255,255));
dc.Rectangle(&rcNew);
dc.SelectObject(pOldbrush);
brush.DeleteObject();
bm.DeleteObject();
dc.RestoreDC(savedc);