You should be able to do all your data sets and retrievals within the DoDataExchange similar to something like this: void Cfirstw32mfcDlg::DoDataExchange(CDataExchange* pDX) { CDHtmlDialog::DoDataExchange(pDX); // data TO controls, means LOAD strings with your existing data or default values // you need to do this BEFORE the DDX_DHtml_ElementInnerText calls if( !pDX->m_bSaveAndValidate ){ EDIT1 = AfxGetApp()->GetProfileString("Settings", "email", "your login"); EDIT2 = AfxGetApp()->GetProfileString("Settings", "password", "details here.."); } // these calls presumably set or get the data from the controls into your string variables DDX_DHtml_ElementInnerText(pDX, _T("email"), EDIT1); DDX_DHtml_ElementInnerText(pDX, _T("password"), EDIT2); DDX_DHtml_ElementInnerText(pDX, _T("Temp_Text1"), m_EDIT1); DDX_DHtml_ElementInnerText(pDX, _T("Temp_Text2"), m_EDIT2); // data FROM controls, means SAVE data from the controls to your storage // you need to do this AFTER the DDX_DHtml_ElementInnerText calls if( pDX->m_bSaveAndValidate ){ GetElementText(_T("email")); AfxGetApp()->WriteProfileString("Settings", "email", EDIT1); GetElementText(_T("password")); AfxGetApp()->WriteProfileString("Settings", "password", EDIT2); } } If the DoDataExchange is correctly implemented, you don't even need to have the OnOK handler, since the DoDataExchange will be called for you (I am pretty sure) and you definitely don't need the Cancel, because the UpdatData (and thus DoDataExchange) is not called at all.