Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
A radio button is a control that appears as a dot surrounded by a round box. In reality, a radio button is accompanied by one or more other radio buttons that appear and behave as a group.
Sr.No.
Name & Description
1
Create
Creates the Windows button control and attaches it to the CButton object.
2
DrawItem
Override to draw an owner-drawn CButton object.
3
GetBitmap
Retrieves the handle of the bitmap previously set with SetBitmap.
4
GetButtonStyle
Retrieves information about the button control style
5
GetCursor
Retrieves the handle of the cursor image previously set with SetCursor.
6
GetIcon
Retrieves the handle of the icon previously set with SetIcon.
7
GetIdealSize
Retrieves the ideal size of the button contro.
8
GetImageList
Retrieves the image list of the button control.
9
GetNote
Retrieves the note component of the current command link control.
10
GetNoteLength
Retrieves the length of the note text for the current command link control.
11
GetSplitGlyph
Retrieves the glyph associated with the current split button control.
12
GetSplitImageList
Retrieves the image list for the current split button control.
13
GetSplitInfo
Retrieves information that defines the current split button control.
14
GetSplitSize
Retrieves the bounding rectangle of the drop-down component of the current split button control.
15
GetSplitStyle
Retrieves the split button styles that define the current split button control.
16
GetState
Retrieves the check state, highlight state, and focus state of a button control.
17
GetTextMargin
Retrieves the text margin of the button control.
18
SetBitmap
Specifies a bitmap to be displayed on the button.
19
SetButtonStyle
Changes the style of a button.
20
SetCheck
Sets the check state of a button control.
21
SetCursor
Specifies a cursor image to be displayed on the button.
22
SetDropDownState
Sets the drop-down state of the current split button control.
23
SetIcon
Specifies an icon to be displayed on the button.
24
SetImageList
Sets the image list of the button control.
25
SetNote
Sets the note on the current command link control.
26
SetSplitGlyph
Associates a specified glyph with the current split button control.
27
SetSplitImageList
Associates an image list with the current split button control.
28
SetSplitInfo
Specifies information that defines the current split button control.
29
SetSplitSize
Sets the bounding rectangle of the drop-down component of the current split button control.
30
SetSplitStyle
Sets the bounding rectangle of the drop-down component of the current split button control.
31
SetState
Sets the highlighting state of a button control.
32
SetTextMargin
Sets the text margin of the button control.
Here is the list of messages mapping for Radio Button control −
Message
Map entry
Description
BN_CLICKED
ON_BN_CLICKED( <id>, <memberFxn> )
The framework calls this member function when is button clicked.
BN_DISABLE
ON_BN_DISABLE( <id>, <memberFxn> )
The framework calls this member function when button is disabled.
BN_DOUBLECLICKED
ON_BN_DOUBLECLICKED( <id>, <memberFxn> )
The framework calls this member function when button is double clicked.
BN_PAINT
ON_BN_PAINT( <id>, <memberFxn> )
The framework calls this member function when an application makes a request to repaint a button.
Let us look into an example of Radio button by creating a new MFC dialog based application.
Step 1 − Drag a group box and three radio buttons and remove the Caption of Static Text control.
Step 2 − Add event handler for all the three radio buttons.
Step 3 − Add the Value variable for the Static Text control.
Step 4 − Here is the implementation of three event handlers.
void CMFCRadioButtonDlg::OnBnClickedRadio1() {
// TODO: Add your control notification handler code here
m_strTextControl = _T("Radio Button 1 Clicked");
UpdateData(FALSE);
}
void CMFCRadioButtonDlg::OnBnClickedRadio2() {
// TODO: Add your control notification handler code here
m_strTextControl = _T("Radio Button 2 Clicked");
UpdateData(FALSE);
}
void CMFCRadioButtonDlg::OnBnClickedRadio3() {
// TODO: Add your control notification handler code here
m_strTextControl = _T("Radio Button 3 Clicked");
UpdateData(FALSE);
}
Step 5 − When the above code is compiled and executed, you will see the following output. When you select any radio button, the message is displayed on Static Text control.