【发布时间】:2013-06-18 11:46:07
【问题描述】:
如何禁用 MFC 对话框的“确定”按钮?
此代码:CWnd* fieldOK = pDlg->GetDlgItem(IDOK);
fieldOK->EnableWindow(FALSE);
导致异常“访问冲突读取位置...”
在 winnocc.cpp 中的 CWnd::EnableWindow(BOOL bEnable) 函数 ASSERT(::IsWindow(m_hWnd) || (m_pCtrlSite != NULL)); 中来自 mfc90d.dll
在此期间,重点是另一个控件。
有什么问题?
感谢您的帮助。
[编辑]
bool CSCalcNormCell::OnSelectionChanged( CWnd* pDlg, int type, int page, UINT ctrl_id )
{
DDX_DataBox(pDX.get(), IDC_WORKSHOP_COMBO, ws_code);
if (!CInfactoryPriceAdapter::CanEditPricesForWorkshop( ws_code ))
{
CWnd* fieldOK = pDlg->GetDlgItem(IDOK);
fieldOK->EnableWindow(FALSE);
}
else
{
CWnd* fieldOK = pDlg->GetDlgItem(IDOK);
fieldOK->EnableWindow(TRUE);
}
}
【问题讨论】: