Tech Support > Microsoft Windows > Development Resources > What defines a group in CheckRadioButton ?
What defines a group in CheckRadioButton ?
Posted by Robert Scott on December 3rd, 2003


I had always allocated control ID numbers manually for groups of radio
buttons, so the order in the dialog box was the same as the order of
the ID values. But today I made a change and added a radio button in
the middle of an existing group. This left the group looking like
this in the resource file:

CONTROL "X-axis", 100, "BUTTON", BS_AUTORADIOBUTTON...WS_GROUP...
CONTROL "Y-axis", 117, "BUTTON", BS_AUTORADIOBUTTON...
CONTROL "Theta-axis",101, "BUTTON", BS_AUTORADIOBUTTON...
CONTROL "Z-axis", 102, "BUTTON", BS_AUTORADIOBUTTON...

Where ID 117 was added. But when I called

CheckRadioButton(hwnd,100,102,ButtonID);

when ButtonID=117, nothing gets checked. When ButtonID is 100, 101,
or 102, it works fine. Then, when I renumbered the IDs to
99,100,101,102 so they were in order again, then everything worked.
This leads me to believe that CheckRadioButton uses the ID value range
defined by its 2nd and 3rd parameters rather than the group defined by
controls appearing in order in the dialog box. Is that right? The
Win32 documentation doesn't say that the ID values have to be in any
particular order. What is going on here?


-Robert Scott
Ypsilanti, Michigan
(Reply through newsgroups, not by direct e-mail, as automatic reply address is fake.)

Posted by Raymond Chen on December 3rd, 2003


I'll have the docs for this clarified. They docs should read

The CheckRadioButton function sends a BM_SETCHECK message to each
control on the dialog which satisfies the below inequality.

nIDFirstButton <+ control id <= nIDLastButton

Note that the GetNextDlgGroupItem function uses a different
algorithm for deciding which controls belong to a group.

Note also that the BM_SETCHECK message is sent regardless of the
control type. The CheckRadioButton function sends the message
even to controls that are not buttons.


On Wed, 03 Dec 2003 02:30:07 GMT, no-one@nowhere-q7x.com (Robert
Scott) wrote:



Similar Posts