Dynamically Disabling/Enabling a Control in a Dialog BoxID: Q108896
|
...
public:
CButton m_button;
...
...
protected:
virtual void DoDataExchange(CDataExchange* pDX);
...
void CMyDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_BUTTON1, m_button);
}
NOTE: If you use Class Wizard to add a member variable in your dialog
box class, it does this for you.
CMyDlg::OnInitDialog()
{
...
m_button.EnableWindow(FALSE);
...
}
An alternative method is to use the CWnd::GetDlgItem() function to get a
CWnd * to the control and then call EnableWindow(). For example:
CMyDlg::OnInitDialog()
{
...
GetDlgItem(IDC_BUTTON)->EnableWindow(FALSE);
...
}
Additional query words: kbinf 1.00 1.50 2.00 2.10 2.50 2.51 2.52 3.00 3.10 4.00
Keywords : kbMFC KbUIDesign kbVC
Version : 1.00 1.50 1.51 1.52 | 1.00 2.00
Platform : NT WINDOWS
Issue type :
Last Reviewed: August 3, 1999