I have a radio button that is a CButton in a CDialog.
When the user clicks the radio button, the function OnClickedRadioButton
is called.
Inside OnClickedRadioButton
I toggle the button by calling this function:
void toggleButton(CButton& theButton)
{
switch(theButton.GetCheck())
{
case BST_UNCHECKED:
{
theButton.SetCheck(BST_CHECKED);
break;
}
case BST_CHECKED:
{
theButton.SetCheck(BST_UNCHECKED);
break;
}
default:
{
theButton.SetCheck(BST_UNCHECKED);
}
}
}
When I compile & run the program: (i) if the radio button is checked on, I can click it to clear it. (ii) if the radio button is unchecked, I click it and nothing happens. But if I click on a different program (i.e. visual studio) and then click back on the CDialog, the radio button checks on.
I've looked & tried functions Cwnd::UpdateDialogControls
and Cwnd::UpdateData
, but I was not able to get these to solve my problem.