Click here to Skip to main content
Licence 
First Posted 2 Dec 2003
Views 110,068
Bookmarked 53 times

CXPGroupBox -- XP style groupbox and window style groupbox

By | 21 Apr 2004 | Article
This class allows you to create XP style groupbox and window style groupbox.

Sample Image - xpgroupbox.jpg

Introduction

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;

to

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:

  m_frmWin.SetXPGroupStyle(CXPGroupBox::XPGB_WINDOW)
          .SetBackgroundColor(RGB(201, 201, 151), RGB(255, 255, 204)) 
          .SetFontBold(TRUE);

 m_frmNormal.SetCatptionTextColor(RGB(16,140,231))
      .SetFontBold(TRUE);

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

History

  • 21 Apr 2004 - updated source and demo

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

JackCa

Web Developer

Canada Canada

Member

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.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralTrouble on getting message Pinmemberxiang_yan23:46 10 Sep '10  
GeneralHi!Hi! Pinmemberbeikexuezi17:35 20 May '10  
Generallicense of XCPGroupBox PinmemberJan77777774:52 10 May '10  
GeneralFormView repaint issue - a ghost stitching problem PinmemberAstronomer14:40 14 Jul '08  
GeneralEnableWindow has no effect PinmemberJoerg Hoffmann23:37 22 Jul '07  
QuestionLicence ??? PinmemberBastianPL4:33 18 Jun '06  
Generalproblem of refresh of Edit box PinmemberFlower30311:15 13 May '06  
Generalproblems with window style Pinmembereli150219793:42 11 Sep '05  
GeneralRe: problems with window style PinmemberJackCa7:09 12 Sep '05  
GeneralNice Class ~~~ But Spread OCX Invisible Pinmemberxboxer21:35 23 Feb '05  
Generalalignment of title Pinmembercgtext5:03 19 Apr '04  
GeneralRe: alignment of title PinmemberJackCa14:37 22 Apr '04  
GeneralVery nice !!! PinmembermYkel8:17 10 Feb '04  
GeneralSome opaque and some invisible PinmemberAAntix6:05 8 Dec '03  
GeneralRe: Some opaque and some invisible PinmemberJackCa8:44 8 Dec '03  
GeneralRe: Some opaque and some invisible PinmemberAAntix9:57 8 Dec '03  
GeneralRe: Some opaque and some invisible PinmemberJackCa10:38 8 Dec '03  
GeneralRe: Some opaque and some invisible PinmemberAAntix21:06 17 Dec '03  
GeneralControls invisible PinsussTomBest21:27 3 Dec '03  
GeneralRe: Controls invisible PinmemberJackCa4:13 4 Dec '03  
GeneralRe: Controls invisible PinmemberAAntix9:59 8 Dec '03  
GeneralRe: Controls invisible Pinmemberkbomb9878:34 11 Dec '03  
GeneralRe: Controls invisible PinmemberTomBest20:51 11 Dec '03  
GeneralRe: Controls invisible PinmemberJackCa3:49 12 Dec '03  
GeneralRe: Controls invisible PinmemberDandy Cheung15:11 14 Jan '04  

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.

Permalink | Advertise | Privacy | Mobile
Web02 | 2.5.120517.1 | Last Updated 22 Apr 2004
Article Copyright 2003 by JackCa
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid