Messages to Buttons

A parent window can send messages to a button in an overlapped or child window by using the SendMessage function. It can send messages to a button in a dialog box by using the SendDlgItemMessage and CheckRadioButton functions.

An application can use the BM_GETCHECK message to retrieve the check state of a check box or radio button. An application can also use the BM_GETSTATE message to retrieve the button's current states, that is, the check state, push state, and focus state.

The BM_SETCHECK message sets the check state of a check box or radio button and the BM_SETSTATE message sets the push state of a button. You can change the style of a button by using the BM_SETSTYLE message, which changes the button styles within a type. For example, it changes a check box to an automatic check box. This message is not designed for changing between types, for example, changing a check box to a radio button. An application should not change a button from one type to another.

You can use the DM_GETDEFID message to retrieve the identifier of the default push button control in a dialog box. You can use the DM_SETDEFID message to set the default push button for a dialog box. When you use the SetFocus function on a dialog box control, you should use the WM_NEXTDLGCTL message, rather than the DM_SETDEFID message, to change the default button style.