Enhanced GroupBox Control


Desktop-as-a-Service Designed for Any Cloud ? Nutanix Frame

Environment: VC6, Win98/NT4/2K

If you want to customize the look of the standard GroupBox control then the SxGroupBox class can be most helpful for you. It provides functions for customizing the font, color, and style. Most of the work is done in the OnPaint message handler. You can easily change the OnPaint function yourself to add other effects such as rounded corners or other line styles or box styles.

You can follow these steps to use the class:
  1. Include the SxGroupBox.h header file in your dialog class header file.
  2. Use class wizard to create a control data member of type CSxGroupBox.  If the CSxGroupBox type does not appear in the class wizard control type combobox then just choose CButton and then manually edit your dialog class header file and replace the CButton with CSxGroupBox.  
  3. Add whatever commands you want to your dialog class cpp file to customize the appearance of the GroupBox.

A sample application is included that shows most of the features of SxGroupBox.

The following code snippet shows how to call some of the functions.

[In File YourDialogClass.h]

#include "SxGroupBox.h"

class YourDialogClass : public CDialog

// Dialog Data
  CSxGroupBox	MyGroupBox;


[In File YourDialogClass.cpp]

void YourDialogClass::YourFunction()
  // create font
  CSxLogFont Arial12b(120,FW_BOLD,false,"Arial");
  // set the custom font, text color, and alignment
  MyGroupBox.SetFont( &Arial12b );
  MyGroupBox.SetTextColor( RGB(100,0,0) );
  MyGroupBox.SetTextAlign( BS_CENTER );
  // set the custom line colors, thickness, and style
  MyGroupBox.SetBoxColors( RGB(100,0,0), RGB(255,100,100) );
  MyGroupBox.SetLineStyle( BS_3D );


Download demo project - 29 Kb
Download source - 5 Kb

This article was originally published on January 30th, 2002

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date