本文介绍了禁用Radiobutton事件的控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我将开发基于mfc对话的应用程序,其中一个场景有3个单选按钮;每当用户点击第3个单选按钮时,对话框上的某些控件应该被禁用!我怎么能这样做?
I am going to develop mfc dialogue based application in which one scenario there is 3 radio buttons; whenever user click on the 3rd radio button, some controls on the dialog should be disable!!! How can I do that??
推荐答案
// Handler function declared in header as
// afx_msg void OnBnClickedRadio();
ON_BN_CLICKED(IDC_RBTN_1, OnBnClickedRadio)
ON_BN_CLICKED(IDC_RBTN_2, OnBnClickedRadio)
ON_BN_CLICKED(IDC_RBTN_3, OnBnClickedRadio)
void CMyDialog::OnBnClickedRadio()
{
// Enable controls if radio button 3 is not checked
CButton *pRadio3 = (CButton*)GetDlgItem(IDC_RBTN_3);
BOOL bEnable = (BST_CHECKED != pRadio3->GetCheck());
// Access control by ID
GetDlgItem(IDC_SOME_CONTROL)->EnableWindow(bEnable);
// Access control by member var
m_SomeOtherControl.EnableWindow(bEnable);
}
这篇关于禁用Radiobutton事件的控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!