Click here to Skip to main content
13,189,506 members (58,234 online)
Click here to Skip to main content
Add your own
alternative version


29 bookmarked
Posted 21 Jun 2001

Draw your control's skin using a pattern brush

, 21 Jun 2001
Rate this:
Please Sign up or sign in to vote.
You can impliment skin control by returning a brush from the OnCtlColor() method
<!-- Download Links --> <!-- Article image -->

Sample Image - brush_skin.jpg

<!-- Main HTML starts here -->


This article shows how to use a pattern brush to give your controls a similar look and feel.

When you use a brush, you can specify the origin of the brush. So, if all your controls use the same brush, your controls have same feature. If you handle the OnCtlColor() and return a pattern brush then you can do this. This is very simple method.

I used code similar to the following functions in my source code.

  • UnrealizeObject() : The UnrealizeObject function resets the origin of a brush or resets a logical palette.
  • CDC::SetBrushOrg() : This method specifies the origin that the GDI assigns to the next brush that the application selects for the device context.

The Main Function

HBRUSH CPatternDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) 
    HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor); 

    CPoint pt(0,0); 

    if (this != pWnd) 
        CRect rc; 
        pt.x = -(rc.left + GetSystemMetrics(SM_CXDLGFRAME) - 1) % 55; 
        pt.y = -( + GetSystemMetrics(SM_CYDLGFRAME) - 1)% 53; 

    // Set brushOrg
    // This is very important!!

    // return new skin-brush!
    return (HBRUSH)brush; 


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

Wooseok Seo
Software Developer (Senior)
Korea (Republic of) Korea (Republic of)
Woo Seok Seo have been a Microsoft MVP for 7 years and have translated several books into Korean. Author of C# Programming for Beginner (DevPress, 2001), he is interested in Debugging techniques and .NET technology. Get in touch with Woo Seok Seo at

You may also be interested in...


Comments and Discussions

Generalthats good, but you would also need to handle onerasebackground to set background of static fields transparent... Pin
sdfghwdfgagf6-Nov-08 5:49
membersdfghwdfgagf6-Nov-08 5:49 
QuestionCan i get the mean of "pt.x = -(rect-&gt;left + GetSystemMetrics(SM_CXDLGFRAME) - 1) % 55;" Pin
luoqi28-May-08 21:11
memberluoqi28-May-08 21:11 
RantExcelent concept, but the delivery could be better Pin
John Crenshaw2-Apr-08 16:40
memberJohn Crenshaw2-Apr-08 16:40 
QuestionThe meaning of "SM_CXDLGFRAME" ? Pin
wzh198312216-Dec-06 13:52
memberwzh198312216-Dec-06 13:52 
GeneralQuestion about the background color Pin
goodoljosh198017-Jul-06 5:02
membergoodoljosh198017-Jul-06 5:02 
GeneralProblem, it doesn't work Pin
gabriel.fischer3-Jan-05 13:16
membergabriel.fischer3-Jan-05 13:16 
GeneralSkinMagic Toolkit Pin
jedyking14-Apr-04 5:21
memberjedyking14-Apr-04 5:21 
QuestionHow to do this in a scrollable dialog? Pin
guosheng5-Apr-04 22:00
memberguosheng5-Apr-04 22:00 
GeneralGreat! Pin
X3m7-May-02 5:23
memberX3m7-May-02 5:23 Pin
Anonymous13-Aug-01 20:44
memberAnonymous13-Aug-01 20:44 

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

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

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.171016.2 | Last Updated 22 Jun 2001
Article Copyright 2001 by Wooseok Seo
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid