Visual C++ and MFC Programming 2nd Edition

(Martin Jones) #1

Visual C++ and MFC Fundamentals Chapter 20: List-Based Controls


If you are programmatically creating the control, specify an appropriate rect value to the
Create() method. Then, set the Multiline property to True or, at run time, add the
BS_MULTILINE style:

Once the text can fit in the allocated area, you can accept the default alignment of the
label or change it as you see fit. The alignment of text is specified using the Horizontal
Alignment and the Vertical Alignment properties. Here are the possible combinations:

Left Text: False
Horz Align: Default or Left
Vert Align: Top

Left Text: False
Horz Align: Default or Left
Vert Align: Default or Center

Left Text: False
Horz Align: Default or Left
Vert Align: Bottom

Left Text: True
Horz Align: Default or Left
Vert Align: Top

Left Text: True
Horz Align: Default or Left
Vert Align: Default or Center

Left Text: True
Horz Align: Default or Left
Vert Align: Bottom

In the same way, you can add other radio buttons and individually configure each. For
harmony, all radio of a group should have the same design.

For either the user or the programmer, radio buttons must behave as entities of one group.
When you freshly add radio buttons to a host, they are created as a group. If your form or
dialog box will be made of only a few radio buttons, you may not need to do much. If
you plan to use more than one set of radio buttons, then you must separate them into
groups. To do that, set the Group property of each new button of a group to True.

Imagine you will use two sets of group buttons on a dialog box. Add the first radio button
and set its Group property to True (checked) or add the WS_GROUP value to its style;
then, add the other radio buttons of the set but set their Group property to False
(unchecked) or do not add the WS_GROUP value to their styles.
Free download pdf