views:

1708

answers:

4

When running an old MFC application in Visual Studio's debugger I've seen a lot of warnings in the Output window like the following:

Warning: skipping non-radio button in group.

I understand that in MFC you put radio buttons in groups to indicate which sets of radio buttons go together. If I remember correctly you do this by setting the "group" property of the first radio button to true, and then set the rest of the radio buttons "group" property to false.

I have three questions about this warning.

  1. How do you get rid of this warning? Do you have to set the "group" property of all non-radio button controls to true to avoid this, or should you just set it for the first control after the last radio button?

  2. Is there an easy way to figure out what controls or dialogs have this problem? I could open each dialog and fiddle with it until the warning pops up. This application has a lot of dialogs though, so it would be nice if there was an easier way.

  3. What negative behavior can occur if you don't fix this warning? In other words, does this even matter?

+1  A: 

Perhaps check your tab order (Format/Tab Order) - sounds like you have a normal pushbutton in the middle of a group of radio buttons. If indeed this is the problem, you can fix this by using the Format/Tab Order menu item, and then clicking on the controls in the correct order.

Smashery
+4  A: 

The warning means that there's some control other than a radio button in the tab order between the first and last radio buttons in the group. A control with the WS_GROUP style set marks the start of a group.

To fix this, use the dialog editor to change the tab order and make sure that all the radio buttons are numbered sequentially. Another way to do this would be to open the .rc file in a text editor and change the order of the statements inside each dialog resource (the tab order is simply defined by the order in which the controls are listed).

I think you can safely ignore this warning, provided the radio button grouping is working correctly.

ChrisN
+1  A: 

Between the responses here and some research in old forums I think I've figured out at least how to fix my problems. Here is what I've found out for my above questions.

  1. ChrisN and Smashery suggested that I reorder the tabs to make sure radio buttons are ordered sequentially, and this did fix some of the warnings.

    Additionally, the first control in the tab order after the radio button group must have the WS_GROUP property set (or the group property set to true in the editor). This tells MFC that the radio button group has ended. Without it all remaining controls in the tab order until the next WS_GROUP will generate the warning. After doing both these things the warnings in these dialogs went away.

  2. This is still an open question, I didn't find a good way to locate these problems without opening each dialog and waiting for warnings.

    If you know a dialog is creating this warning but you don't know what control is causing it, you can set a breakpoint in the DDX_Radio() function on the TRACE() call that generates the warning. This can make it easier to identify the specific control that is being complained about.

  3. I agree with ChrisN, I can't think of any reason for this warning other than to make you double check your tab order. Elsewhere online I can't find any other reference to a problem that this might cause.

ryan_s
A: 

For point 2, which is why I guess you're keeping this unanswered, I can't picture anything simplier then doing a text search (*.rc) for all dialogs with radio buttons. For each hit, visually inspect the resource code for this issue and correct it. I'd do it by hand in the resource file's source vs. trying to play with the gui designer.

Aardvark