Click here to Skip to main content
13,196,126 members (54,311 online)
Click here to Skip to main content
Add your own
alternative version


59 bookmarked
Posted 2 Dec 2003

CXPGroupBox -- XP style groupbox and window style groupbox

, 21 Apr 2004
Rate this:
Please Sign up or sign in to vote.
This class allows you to create XP style groupbox and window style groupbox.

Sample Image - xpgroupbox.jpg


Recently, I was coding an application. I needed XP style groupbox and a window style groupbox. I did some research, but I could not find it. So I decided to write it.

How to Use it

I derived the class CXPGroupBox from CButton. It is easy to use. In the dialog resource editor, add a groupbox as usual and give an ID to the groupbox. Then use class wizard to create a member to link the groupbox. Remember, select category as "Control", and variable type as CButton.

Then go to Dialog header file and add:

#include "XPGroupBox.h" 

and also change the control type CButton to CXPGroupBox. For example, change:

CButton m_frmXPGroupBox;


CXPGroupBox m_frmXPGroupBox;

Then in the CPP file of the dialog class, in the OnInitDialog() function, add init code for the groupbox. In the demo file, it shows:

         .SetBackgroundColor(RGB(201, 201, 151), RGB(255, 255, 204))


m_frmWin is the new style groupbox, it looks like a window and m_frmNormal is XP style groupBox.

Enjoy it.

Class function list

virtual CXPGroupBox& SetBorderColor(COLORREF clrBorder);
virtual CXPGroupBox& SetCatptionTextColor(COLORREF clrText);
virtual CXPGroupBox& SetBackgroundColor(COLORREF clrBKClient);
virtual CXPGroupBox& SetBackgroundColor(COLORREF clrBKTilte,  
                                COLORREF clrBKClient);
virtual CXPGroupBox& SetXPGroupStyle(XPGroupBoxStyle eStyle); 

virtual CXPGroupBox& SetText(LPCTSTR lpszTitle);
virtual CXPGroupBox& SetFontBold(BOOL bBold);
virtual CXPGroupBox& SetFontName(const CString& strFont, 
                                BYTE byCharSet = ANSI_CHARSET);
virtual CXPGroupBox& SetFontUnderline(BOOL bSet);
virtual CXPGroupBox& SetFontItalic(BOOL bSet);
virtual CXPGroupBox& SetFontSize(int nSize);
virtual CXPGroupBox& SetFont(LOGFONT lf);

In the class, you can set font attributes like font name, color, size, bold, italic etc. You can change the background color of the window style groupbox and XP style groupbox as well. If you change the background color of groupbox, you will have to make the style of the controls in the groupbox transparent. Otherwise it is urgly. :)


  • 21 Apr 2004 - updated source and demo


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

Web Developer
Canada Canada
I have been programming over 6 years in many languages and architectures, but the most is C++, VB, Java, ASP and now towards C#.

I am living in Toronto. I like to spend my quality time with my family.

You may also be interested in...

Comments and Discussions

GeneralTrouble on getting message Pin
xiang_yan10-Sep-10 23:46
memberxiang_yan10-Sep-10 23:46 
GeneralRe: Trouble on getting message Pin
xiaoyintao11-Mar-13 19:46
memberxiaoyintao11-Mar-13 19:46 
GeneralHi!Hi! Pin
beikexuezi20-May-10 17:35
memberbeikexuezi20-May-10 17:35 
Hi,I need it.I'm a colledge student!
Generallicense of XCPGroupBox Pin
Jan777777710-May-10 4:52
memberJan777777710-May-10 4:52 
GeneralFormView repaint issue - a ghost stitching problem Pin
Astronomer14-Jul-08 14:40
memberAstronomer14-Jul-08 14:40 
GeneralEnableWindow has no effect Pin
Joerg Hoffmann22-Jul-07 23:37
memberJoerg Hoffmann22-Jul-07 23:37 
QuestionLicence ??? Pin
BastianPL18-Jun-06 4:33
memberBastianPL18-Jun-06 4:33 
Generalproblem of refresh of Edit box Pin
Flower30313-May-06 11:15
memberFlower30313-May-06 11:15 
Generalproblems with window style Pin
eli1502197911-Sep-05 3:42
membereli1502197911-Sep-05 3:42 
GeneralRe: problems with window style Pin
JackCa12-Sep-05 7:09
memberJackCa12-Sep-05 7:09 
GeneralNice Class ~~~ But Spread OCX Invisible Pin
xboxer23-Feb-05 21:35
memberxboxer23-Feb-05 21:35 
Generalalignment of title Pin
cgtext19-Apr-04 5:03
membercgtext19-Apr-04 5:03 
GeneralRe: alignment of title Pin
JackCa22-Apr-04 14:37
memberJackCa22-Apr-04 14:37 
GeneralVery nice !!! Pin
mYkel10-Feb-04 8:17
membermYkel10-Feb-04 8:17 
GeneralSome opaque and some invisible Pin
AAntix8-Dec-03 6:05
memberAAntix8-Dec-03 6:05 
GeneralRe: Some opaque and some invisible Pin
JackCa8-Dec-03 8:44
memberJackCa8-Dec-03 8:44 
GeneralRe: Some opaque and some invisible Pin
AAntix8-Dec-03 9:57
memberAAntix8-Dec-03 9:57 
GeneralRe: Some opaque and some invisible Pin
JackCa8-Dec-03 10:38
memberJackCa8-Dec-03 10:38 
GeneralRe: Some opaque and some invisible Pin
AAntix17-Dec-03 21:06
memberAAntix17-Dec-03 21:06 
GeneralControls invisible Pin
TomBest3-Dec-03 21:27
sussTomBest3-Dec-03 21:27 
GeneralRe: Controls invisible Pin
JackCa4-Dec-03 4:13
memberJackCa4-Dec-03 4:13 
GeneralRe: Controls invisible Pin
AAntix8-Dec-03 9:59
memberAAntix8-Dec-03 9:59 
GeneralRe: Controls invisible Pin
kbomb98711-Dec-03 8:34
memberkbomb98711-Dec-03 8:34 
GeneralRe: Controls invisible Pin
TomBest11-Dec-03 20:51
memberTomBest11-Dec-03 20:51 
GeneralRe: Controls invisible Pin
JackCa12-Dec-03 3:49
memberJackCa12-Dec-03 3:49 

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
Web03 | 2.8.171019.1 | Last Updated 22 Apr 2004
Article Copyright 2003 by JackCa
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid