You can define dialog-window buttons as part of a dialog template in a resource-definition file, as shown in the following Resource Compiler source-code fragment.
DLGTEMPLATE IDD_BUTTON BEGIN DIALOG "", 2, 10, 10, 235, 180, WS_VISIBLE, FCF_DLGBORDER BEGIN AUTORADIOBUTTON "Radio~1", ID_RADIO1, 15, 80, 45, 12, WS_GROUP AUTORADIOBUTTON "Radio~2", ID_RADIO2, 15, 60, 45, 12 AUTORADIOBUTTON "Radio~3", ID_RADIO3, 15, 40, 45, 12 AUTORADIOBUTTON "Radio~4", ID_RADIO4, 15, 20, 45, 12 PUSHBUTTON "Button 1", ID_PUSH1, 20 100, 50, 14, WS_GROUP PUSHBUTTON "Button 2", ID_PUSH2, 75, 100, 50, 14, WS_GROUP PUSHBUTTON "Button 3", ID_PUSH3, 130, 100, 50, 14, WS_GROUP CHECKBOX "Check Box 1", ID_CHECK1, 150, 65, 65, 12, WS_GROUP CHECKBOX "no toggle", ID_CHECK2, 150, 40, 58, 12, WS_GROUP AUTOCHECKBOX "Check Box 3", ID_CHECK3, 150, 20, 65, 12, WS_GROUP DEFPUSHBUTTON "OK", DID_OK, 75, 26, 46, 20, WS_GROUP END ENDEach button in a dialog window has an identifier (for example, ID_RADIO1) that allows an application to identify the source of the WM_COMMAND and WM_CONTROL messages. An application can use the identifier as the second argument of the WinWindowFromID function to retrieve the button-window handle.
The dialog template also contains the text for each button. For push buttons, this text is displayed in a rectangular box. If the text is too long to fit in the box, the text is clipped. For radio buttons and check boxes, text is displayed to the right of the button. A user selects the button by clicking either the button or the text itself.
The WS_GROUP style identifies the beginning of each new group of buttons. In the preceding example, the four auto-radio buttons are in the same group, and each of the other buttons is in its own group. The auto-radio buttons in the first group can be selected one at a time only. An application must ensure that only one check box in a group is selected at a time. The order in which items can be selected in the group can wrap around from the end of the item list to its beginning.
Notice that the DEFPUSHBUTTON style in the preceding example has the identifier DID_OK. It is customary to include an OK button with this identifier in most dialog windows to provide a uniform user interface. The DEFPUSHBUTTON style draws a thick border around a button and allows a user to select the button by pressing the spacebar.
The dialog-window procedure for a dialog window that contains buttons must respond to WM_COMMAND and WM_CONTROL messages. A common strategy is to use auto-radio buttons and auto-check boxes to let the user set a list of capabilities for a command, and, then, let the user execute the command by choosing an OK push button. With this strategy, the dialog-window procedure ignores all WM_CONTROL messages that come from auto-radio buttons and auto-check boxes. When the dialog-window procedure receives a WM_COMMAND message for the OK push button, the procedure should query the auto-radio buttons and auto-check boxes to determine which options have been selected.