开发者

State of button controlled by a check-box

I have a dialog box with a check-box and a button. I want to make the button ena开发者_如何学JAVAbled/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.


Add an eventhandler for checkbox-click, where you call

UpdateData(TRUE);
pButton->EnableWindow(bFlag);

This should do the trick.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜