我正在尝试检查单选按钮,我是 c++ 和 MFC 的新手,所以经过一番搜索后我写道:
INT m_nIndex;
CButton* pButton1 = (CButton*) GetDlgItem(IDC_RADIO1);
CButton* pButton2 = (CButton*) GetDlgItem(IDC_RADIO2);
pButton1->SetCheck(m_nIndex == 0);
pButton2->SetCheck(m_nIndex == 1);
if (pButton1.IsChecked){ //Here pButton1 shows an error saying expression much have a class type
}
如何调用 radioButton?
另一个问题,如何让单选按钮默认选中?
最佳答案
if
是这样解决的:
if (IsDlgButtonChecked(IDC_RADIO1))
{
}
我只是在初始化程序中调用 SetCheck
来设置我的单选按钮。不确定这是否是您默认的意思
关于c++ - 检查单选按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33424178/