OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
Constructing Check Boxes and Radio Buttons

TCheckBox and TRadioButton each has a constructor that takes the seven parameters commonly found in a control object constructor (a parent window, a resource identifier, the control's x, y, h, and w dimensions, and an optional module pointer).

They also take a text string and a pointer to a group box object that groups the selection boxes. If the group box object pointer is zero, the selection box is not part of a group box. Here are one each of their constructors:

TCheckBox(TWindow *parent, int resourceId, const char far *title,
int x, int y, int w, int h, TGroupBox *group = 0, TModule *module = 0);
TRadioButton(TWindow *parent, int resourceId, const char far *title, int x, int y, int w, int h,
TGroupBox *group = 0, TModule *module = 0);

The following listing shows some typical constructor calls for selection boxes.

CheckBox = new TCheckBox(this, ID_CHECKBOX, "Check Box Text", 158, 12, 150, 26);
GroupBox = new TGroupBox(this, ID_GROUPBOX, "Group Box", 158, 102, 176, 108);
RButton1 = new TRadioButton(this, ID_RBUTTON1, "Radio Button 1", 174, 128, 138, 24, GroupBox);
RButton2 = new TRadioButton(this, ID_RBUTTON2, "Radio Button 2", 174, 162, 138, 24, GroupBox);

Check boxes by default have the BS_AUTOCHECKBOX style, which means that Windows handles a click on the check box by toggling the check box. Without BS_AUTOCHECKBOX, you would have to set the check box's state manually. Radio buttons by default have the BS_AUTORADIOBUTTON style, which means that Windows handles a click on the radio button by checking the radio button and unchecking the other radio buttons in the group. Without BS_AUTORADIOBUTTON, you would have to intercept the radio button's notification messages and do this work yourself.

See Also