views:

332

answers:

2

I have added 8 radio buttons in my dialog layout in the resource manager, but I am having trouble separating them into 2 groups of 4 buttons. I have attempted to add a control variable, but I don't see the option of CButton available in the drop-down menu in the wizard. What would be the easiest method to accomplish this goal?

+5  A: 
  1. Make sure the first control in each group has the "Group" and "Tab Stop" attribute set.
  2. Make sure that the control following the last radio button in each group has the "Group" attribute set.
  3. Make sure that all the radio button IDs in each group are consecutive integers.
  4. Create an integer member variable for each group
  5. In the DoDataExchange method for the dialog add a DDX_Radio statement for each group linking the integer variable to the first ID in the group.

The integer variables will be set from the radio buttons whenever UpdateData(true) is called (called automatically by the default OnOk() handler) and the radio buttons can be set from the variables by calling UpdateData(false) (happens automatically in the default handling of OnInitDialog)

Bruce Ikin
Thanks. Your suggestion worked out well.
stanigator
A: 

This problem is not a MFC problem, but a WIN32 radio button problem.

When creating the groups, the tab order (creation order) matters. You have to create them in order of the first group then the second group. The fist radio button control in each group has to have the "group" style selected.

You should be able to create the radio buttons in the Visual Studio dialog editor and run the Test Dialog and it radio groups should work ok within the two groups without any code at all. If they don't then you have done something wrong.

I found this using google which may help you.

Shane Powell
I already read the link that you have found through google, yet I was still confused after reading through the article. Thanks for your suggestion though. I would take a look at it.
stanigator