Hello,
I have a group of 3 radio buttons with IDs:
Code:
IDC_RADIO_ONE
IDC_RADIO_TWO
IDC_RADIO_THREE
Only IDC_RADIO_ONE has the Group property set to True. The rest are false. I have an int declared as:
Code:
int iRadioSelection_;
which is initialized to 0 in the class constructor.
Next I have:
Code:
void RadioDialog::DoDataExchange(CDataExchange* pDX)
{
DDX_Radio(pDX, IDC_RADIO_ONE, iRadioSelection_);
...
}
BEGIN_MESSAGE_MAP(RadioDialog, CDialog)
ON_BN_CLICKED(IDC_RADIO_ONE, &ConfigureDialog::OnBnClickedRadioSelection)
ON_BN_CLICKED(IDC_RADIO_TWO, &ConfigureDialog::OnBnClickedRadioSelection)
ON_BN_CLICKED(IDC_RADIO_THREE, &ConfigureDialog::OnBnClickedRadioSelection)
...
END_MESSAGE_MAP()
void RadioDialog::OnBnClickedRadioSelection()
{
if(iRadioSelection_== 0)
{
((CButton*)GetDlgItem(IDC_RADIO_ONE))->SetCheck(true);
((CButton*)GetDlgItem(IDC_RADIO_TWO))->SetCheck(false);
((CButton*)GetDlgItem(IDC_RADIO_THREE))->SetCheck(false);
}
else if(iRadioSelection_== 1)
{
((CButton*)GetDlgItem(IDC_RADIO_ONE))->SetCheck(false);
((CButton*)GetDlgItem(IDC_RADIO_TWO))->SetCheck(true);
((CButton*)GetDlgItem(IDC_RADIO_THREE))->SetCheck(false);
}
else if(iRadioSelection_== 2)
{
((CButton*)GetDlgItem(IDC_RADIO_ONE))->SetCheck(false);
((CButton*)GetDlgItem(IDC_RADIO_TWO))->SetCheck(false);
((CButton*)GetDlgItem(IDC_RADIO_THREE))->SetCheck(true);
}
}
This does not seem to work. Am I missing something here?
Thanks!