windows_programming_notes.nbk: Home | Index | Next Page: win32 articles | Previous Page: Using Messages and Message Queues


 Using Radio Buttons

A radio button can be one of two styles: standard or automatic, as defined by the style constants BS_RADIOBUTTON and BS_AUTORADIOBUTTON. Each style can assume two check states: checked (a dot in the button) or cleared (no dot in the button).

When the user selects either state, the radio button receives the keyboard focus. The system sends the button's parent window a WM_COMMAND message containing the BN_CLICKED notification code. The parent window need not handle this message if it comes from an automatic radio button, because the system automatically sets the check state for that style. But the parent window should handle the message if it comes from a non-automatic radio button, because the parent window is responsible for setting the check state for that style. Regardless of the radio button style, the system automatically repaints the button as its state changes.

Radio buttons are arranged in groups, and only one button in the group can be checked at any time. If the WS_GROUP flag is set for any radio button, that button is the first button in a group, and all buttons that follow it immediately in the tab order (but do not themselves have the WS_GROUP flag) are part of its group. If no radio buttons have the WS_GROUP flag, all the radio buttons in the dialog box are treated as a single group.

The application can ascertain whether a radio button is checked by using the IsDlgButtonChecked function.


windows_programming_notes.nbk: Home | Index | Next Page: win32 articles | Previous Page: Using Messages and Message Queues


Notebook exported on Monday, 7 July 2008, 18:56:50 PM Eastern Daylight Time