The problem is that the button control has not yet been created on the interface. We do not get a full vision of your problem.
In any case, you must protect your code from crashes. It is better that your code does nothing to minimize the application. Restructuring thus eliminates the issue of access violation due to a NULL pointer:
bool CSCalcNormCell::OnSelectionChanged( CWnd* pDlg, int type, int page, UINT ctrl_id ) { DDX_DataBox(pDX.get(), IDC_WORKSHOP_COMBO, ws_code); CWnd* fieldOK = pDlg->GetDlgItem(IDOK); if (fieldOK) { if (!CInfactoryPriceAdapter::CanEditPricesForWorkshop( ws_code )) fieldOK->EnableWindow(FALSE); else fieldOK->EnableWindow(TRUE); } }
source share