[ACCEPTED]-Programmatically select an MFC radio button-mfc
Accepted answer
Use CWnd::CheckRadioButton to set select one button in a group 4 and CWnd::GetCheckedRadioButton to retrieve the ID of the selected 3 button. Be sure to call these methods on 2 your dialog object, and not any of the radio 1 button objects.
Radio buttons and check buttons are just 1 buttons. Use a CButton
control and use GetCheck
/SetCheck
.
Going on what mos said, the following worked 1 did the trick:
CButton* pButton = (CButton*)GetDlgItem(IDC_RADIOBUTTON);
pButton->SetCheck(true);
void CMyDlg::DoDataExchange(CDataExchange* pDX)
{
...
DDX_Radio(pDX, IDC_RADIO1, m_Radio);
...
}
but it is the same thing Wizard generates
0
You can use this one-liner:
::SendMessage(GetDlgItem(IDC_RADIO1)->m_hWnd, BM_SETCHECK, BST_CHECKED, NULL);
0
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.