1.普通按钮-Button
2.单选按钮-RadioButton
3.复选框按钮-CheckBox
修改控件ID,添加变量名
(1)点击“确定”Button,将编辑框更新为选中“城市”
1.创建CString类型变量,存在CheckBox被选中的城市名
2.每个城市变量.GetCheck() == 1,意味着该复选框被选中
3.更新,即将变量strCitySelect的值,更新到编辑框IDC_EDIT_city上(使用SetDlgItemText(IDC_EDIT_city, strCitySelect); )
(2)点击单选框RadioButton,先将所有复选框禁用+非选用状态
1.定义void CButtonDlg::InitAllCheckBoxStaus()函数
2.打开ButtonDlg.h头文件,添加void InitAllCheckBoxStaus();
(3)点击省份单选框RadioButton,只开启所属城市
1.广东
void CButtonDlg::OnBnClickedRadioGuangdong()
{
// TODO: 在此添加控件通知处理程序代码
InitAllCheckBoxStaus();
m_guangzhou.EnableWindow(true);
m_shenzhen.EnableWindow(true);
}
2.浙江
void CButtonDlg::OnBnClickedRadioZhejiang()
{
// TODO: 在此添加控件通知处理程序代码
InitAllCheckBoxStaus();
m_hangzhou.EnableWindow(true);
m_ningbo.EnableWindow(true);
}
3.山东
void CButtonDlg::OnBnClickedRadioShandong()
{
// TODO: 在此添加控件通知处理程序代码
InitAllCheckBoxStaus();
m_jinan.EnableWindow(true);
m_qingdao.EnableWindow(true);
}