void CRadioDlg::OnOK()
{
// TODO: Add extra validation here
UINT nLes=GetCheckedRadioButton(IDC_RADIO1,IDC_RADIO2);
UINT nTea=GetCheckedRadioButton(IDC_RADIO3,IDC_RADIO4);
CString msg="课程:";
switch(nLes)
{
case IDC_RADIO1:
msg+="语文;";
break;
case IDC_RADIO2:
msg+="数学;";
break;
}
msg+="老师:";
switch(nTea)
{
case IDC_RADIO3:
msg+="老师1;";
break;
case IDC_RADIO4:
msg+="老师2;";
break;
}
MessageBox(msg);
// CDialog::OnOK();
}
//初始化
// TODO: Add extra initialization here
((CButton*)GetDlgItem(IDC_RADIO1))->SetCheck(BST_CHECKED);
((CButton*)GetDlgItem(IDC_RADIO3))->SetCheck(BST_CHECKED);
注意GROUP的属性,从第一个选中到下一个选中间为一组
本文地址:http://com.8s8s.com/it/it22059.htm