Home

Group Boxes

 

Overview

A group box is a static control used to create "physical" limits or sections on a dialog box or a form. It belongs to the family of MFC static controls.

To create a group box, from the Controls toolbox, click the Group Box button and click the desired area on the dialog box or the form. Because this is a CStatic object, if you plan to refer to it in your code, you must change its ID from IDC_STATIC to something else.

Properties of a Group Box

The most significant property of a group box is probably the text it is displaying. This is set using the Caption field. If you are programmatically creating the control, the first argument of the CStatic::Create() method allows you to set its caption. At run time, to change this text, call the CWnd::SetWindowText() method.

The text of a group box can be aligned to the left, the center, or the right sides of its allocated rectangle. This is specified at design time using the Horizontal Alignment combo box.

Instead of using its own caption, you may want to display a check box that would validate or invalidate the content of the group box. To do this, after adding the group box, delete its caption. Then add a Check Box control where the caption was:

Of course, it is up to you to implement the behavior of controls inside or outside the group box.

 

Group Box Messages

If you plan to send message from the group box itself (not the controls inside of it), check the Notify check box or set it to True. This is equivalent to adding the SS_NOTIFY style when dynamically creating the button.

Articles implementing a Group Box control:

Net Price
Danillo Pizza
Strings in Dialog Box Controls
Dialog Data Transfer

Copyright © 2004-2005 FunctionX, Inc.