Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

A cool GDI pattern brush tool with C++ source code

0.00/5 (No votes)
27 Aug 2003 1  
A cool GDI pattern brush tool with C++ source code, You can create a new office xp style pattern fill mode quickly

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);

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here