Click here to Skip to main content
Click here to Skip to main content

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

By , 27 Aug 2003
Rate this:
Please Sign up or sign in to vote.

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

About the Author

ucc801

China China
No Biography provided

Comments and Discussions

 
GeneralColor and Transparency Pinmemberfoufou27-Apr-08 0:11 
GeneralReally a nice article PinmemberSaRath 21-May-06 19:28 
GeneralRe: Really a nice article Pinmemberjoyjjjz25-Sep-08 17:20 
GeneralA little imagination goes a long way!! PinmemberWREY29-Aug-03 16:51 
GeneralUsability suggestion PinmemberYoSilver28-Aug-03 23:05 
GeneralRe: Usability suggestion Pinmemberucc80129-Aug-03 0:09 
GeneralGreat tool! PinsussAnonymous28-Aug-03 4:03 
GeneralRe: Great tool! PinmemberWarren Stevens28-Aug-03 7:13 
GeneralAnonymous = comment by author Pinmemberdog_spawn28-Aug-03 14:58 
GeneralRe: Anonymous = comment by author Pinmemberdang!28-Aug-03 17:24 
Generalheh Pinmemberdog_spawn28-Aug-03 18:52 
GeneralRe: heh PinmemberErnest Laurentin29-Aug-03 4:10 
GeneralSuggestion Pinmemberdog_spawn28-Aug-03 3:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web01 | 2.8.140421.2 | Last Updated 28 Aug 2003
Article Copyright 2003 by ucc801
Everything else Copyright © CodeProject, 1999-2014
Terms of Use
Layout: fixed | fluid