BUG: Radio Button with BS_AUTORADIOBUTTON Style Enters Endless Loop (261192)
The information in this article applies to:
- Microsoft Platform Software Development Kit (SDK) 1.0
This article was previously published under Q261192 SYMPTOMS
If a button with the BS_AUTORADIOBUTTON style is clicked and is followed in the tab order by a child dialog box, it enters an endless loop.
This endless loop can also be entered if the radio button is hidden and enabled, no other control has the WS_GROUP style, and the radio button's keyboard shortcut is pressed.
CAUSE
When a button with the BS_AUTORADIOBUTTON style releases capture, it enters into a loop, turning off all other radio buttons in its group. The button does this by searching for the next control with the WS_GROUP style (by using the GetNextDlgGroupItem function), in a loop, until it comes back to itself. When this radio button is followed in the tab order by a child dialog box, GetNextDlgGroupItem enters the child dialog box and returns the handle to a control in this dialog box. In the next iteration of the loop, GetNextDlgGroupItem returns the parent of the control, which is the handle to the child dialog box. This action causes GetNextDlgGroupItem to return handles to its child windows and it cannot come out of the child dialog box.
RESOLUTION
A different control with the WS_GROUP style must be placed after the radio buttons to prevent GetNextDlgGroupItem from entering the child dialog box.
STATUSMicrosoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article. MORE INFORMATION
The problem is actually caused when a sibling of the radio button has the WS_EX_CONTROLPARENT style. When GetNextDlgGroupItem encounters a window with the WS_EX_CONTROLPARENT style, it will recurse into that window and enumerate its children looking for a window with the WS_GROUP style. The problem is that GetNextDlgGroupItem never exits this recursive call and simply keeps cycling through the child windows of the sibling window with the WS_EX_CONTROLPARENT style.
The conditions that GetNextDlgGroupItem uses to determine when to return is that it either finds a window with the WS_GROUP style or finds the window specified in the hCtl parameter.
If adding a control with the WS_GROUP style after the radio button group is not acceptable, the only other alternative is to not use BS_AUTORADIOBUTTON style and perform the work that Windows would do if the style was set.
Modification Type: | Minor | Last Reviewed: | 7/11/2005 |
---|
Keywords: | kbbug kbpending KB261192 |
---|
|