1.创建单选框的关联变量,并赋予初始值
//给单选框添加单选变量并给初始值 pRadio1 = (CButton*)GetDlgItem(IDC_RADIO1); pRadio2 = (CButton*)GetDlgItem(IDC_RADIO2); pRadio3 = (CButton*)GetDlgItem(IDC_RADIO3); pRadio4 = (CButton*)GetDlgItem(IDC_RADIO4); pRadio1->SetCheck(1);
2.读取单选值
//单选框
void CDialogDlg::OnButton3()
{
//
TODO: Add your control notification handler code here
CString str;
m_RadioState = 0;
m_RadioState = pRadio1->GetCheck();
m_RadioState +=
(pRadio2->GetCheck())*2;
m_RadioState +=
(pRadio3->GetCheck())*3;
m_RadioState +=
(pRadio4->GetCheck())*4;
str = ‘0‘+m_RadioState;
MessageBox(str);
}
原文:http://www.cnblogs.com/yuqilihualuo/p/3580060.html