I have a dialog box with a check-box and a button. I want to make the button enabled/disabled depending on the state of the check-box.
I have tried achieving this using ON_UPDATE_COMMAND_UI:
...
DDX_Check(pDX, IDC_CHECK1, bFlag);
...
ON_UPDATE_COMMAND_UI(IDC_BUTTON1, OnUpdateButton1)
...
void ColorDialog::OnUpdateButton1(CCmdUI* pCmdUI)
{
pCmdUI->Enable(bFlag);
}
But nothing happens. Checking/unchecking the check-box does nothing to the button.
What am I doing wrong here?
ON_UPDATE_COMMAND_UI is relevant only for menu items amd toolbar buttons. You have to add ON_BN_CLICKED to your message map.