|
A group box is a static control used to set a visible or
programmatic group of controls. A group box primarily draws a rectangular
box where it is positioned. This creates an impression of controls that
would be treated as a group. A group can then be used for its ability to
show a limiting box that encompasses some controls on the dialog box or form
but, as we will see when studying radio buttons, a group box can be used to
create a group of controls where such controls should or must be treated as
one entity.
|
To visually create a group box, from the Toolbox,
click the Group Box button
and click the desired area of the dialog box. To programmatically create a
group box, declare a pointer to CWnd, initialize it with the new
operator, and call the Create() member function. Specify the class
name as STATIC.
Characteristics of the Group Box
|
|
Group Boxes and Data Exchange
|
|
In most circumstances, you can use a group control
without referring to it programmatically. If you had visually added the
control to your application and you plan to refer to it in your code, you
should change its identifier to something other than IDC_STATIC.
The Caption of a Group Box
|
|
As stated already, one of the most regular roles of a
group box is to create a group of controls visibly delimited by a
rectangular frame. To indicate what the group represents, the group box is
equipped with a Caption property for which you supply a string.
By default, the text of the group box' caption is
aligned to the left. Alternatively, you can position it to the center or
the right by selecting the desired value in the Horizontal Alignment combo
box of the Properties window:
Horizontal Alignment: Default Horizontal
Alignment: Left |
Horizontal Alignment: Center |
Horizontal Alignment: Right |
|
|
|
To programmatically change the caption of the control,
call the CWnd::SetWindowText() member function.
All other
properties of a group box are those of a STATIC control.