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 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);
if (this != pWnd)
pt.x = -(rc.left + GetSystemMetrics(SM_CXDLGFRAME) - 1) % 55;
pt.y = -(rc.top + GetSystemMetrics(SM_CYDLGFRAME) - 1)% 53;
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.
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 email@example.com