FIX: Disabled DDX Radio Button Causes Infinite Loop (114980)
The information in this article applies to:
- The Microsoft Foundation Classes (MFC), when used with:
- Microsoft Visual C++ for Windows, 16-bit edition 1.0
- Microsoft Visual C++ for Windows, 16-bit edition 1.5
- Microsoft Visual C++, 32-bit Editions 1.0
This article was previously published under Q114980 SYMPTOMS
When DDX_Radio() is used to perform dialog data exchange (DDX) with a
group of radio buttons, it loops continuously if the first button in the
group has been disabled (either programmatically or with a resource
editor such as App Studio).
CAUSE
This behavior is a result of the way DDX_Radio() determines when it has
traversed every control in a group. The handle of the initial control is
stored. A loop runs, which gets the handle of each successive control in
the group with ::GetNextDlgGroupItem, and terminates when it sees the
handle of the first control again. Unfortunately the function
::GetNextDlgGroupItem skips disabled controls, which is by design.
Therefore the handle to the first control is not returned from the function
(because it is disabled) and therefore the loop does not terminate.
RESOLUTION
To work around this problem, do one of the following: - Arrange the group so that the first radio button is not disabled when
any of the other controls in the group are enabled.
-or-
- Call EnableWindow() to enable the radio button before DDX_Radio() is
called [for example, in DoDataExchange()].
-or-
- Write your own DDX_Radio() replacement, as shown in the sample code in
the "MORE INFORMATION" section, below.
STATUS
Microsoft has confirmed this to be a problem in Microsoft Foundation
Classes, versions 2.0 and 2.5. This problem was corrected in MFC version
3.0
Modification Type: | Major | Last Reviewed: | 12/2/2003 |
---|
Keywords: | kbbug kbfix KbUIDesign KB114980 |
---|
|