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

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. Smile | :)


  • 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.

Comments and Discussions

GeneralTrouble on getting message Pinmemberxiang_yan11-Sep-10 0:46 
GeneralRe: Trouble on getting message Pinmemberxiaoyintao11-Mar-13 20:46 
GeneralHi!Hi! Pinmemberbeikexuezi20-May-10 18:35 
Hi,I need it.I'm a colledge student!
Generallicense of XCPGroupBox PinmemberJan777777710-May-10 5:52 
GeneralFormView repaint issue - a ghost stitching problem PinmemberAstronomer14-Jul-08 15:40 
GeneralEnableWindow has no effect PinmemberJoerg Hoffmann23-Jul-07 0:37 
QuestionLicence ??? PinmemberBastianPL18-Jun-06 5:33 
Generalproblem of refresh of Edit box PinmemberFlower30313-May-06 12:15 
Generalproblems with window style Pinmembereli1502197911-Sep-05 4:42 
GeneralRe: problems with window style PinmemberJackCa12-Sep-05 8:09 
GeneralNice Class ~~~ But Spread OCX Invisible Pinmemberxboxer23-Feb-05 22:35 
Generalalignment of title Pinmembercgtext19-Apr-04 6:03 
GeneralRe: alignment of title PinmemberJackCa22-Apr-04 15:37 
GeneralVery nice !!! PinmembermYkel10-Feb-04 9:17 
GeneralSome opaque and some invisible PinmemberAAntix8-Dec-03 7:05 
GeneralRe: Some opaque and some invisible PinmemberJackCa8-Dec-03 9:44 
GeneralRe: Some opaque and some invisible PinmemberAAntix8-Dec-03 10:57 
GeneralRe: Some opaque and some invisible PinmemberJackCa8-Dec-03 11:38 
GeneralRe: Some opaque and some invisible PinmemberAAntix17-Dec-03 22:06 
GeneralControls invisible PinsussTomBest3-Dec-03 22:27 
GeneralRe: Controls invisible PinmemberJackCa4-Dec-03 5:13 
GeneralRe: Controls invisible PinmemberAAntix8-Dec-03 10:59 
GeneralRe: Controls invisible Pinmemberkbomb98711-Dec-03 9:34 
GeneralRe: Controls invisible PinmemberTomBest11-Dec-03 21:51 
GeneralRe: Controls invisible PinmemberJackCa12-Dec-03 4:49 

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 | Terms of Use | Mobile
Web03 | 2.8.150301.1 | Last Updated 22 Apr 2004
Article Copyright 2003 by JackCa
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid