void CuDlgReplicationServerPageStartupSetting::OnButtonRestore() { UINT nState = 0; CString strMessage; int answ, nCount = m_cListCtrl.GetItemCount(),iIndex = -1; m_cListCtrl.HideProperty(TRUE); iIndex = m_cListCtrl.GetNextItem (-1, LVNI_SELECTED); if (iIndex == -1) return; CaReplicationItem* pItem = (CaReplicationItem*)m_cListCtrl.GetItemData(iIndex); if (!pItem) return; //"Do you want to restore '%s' " //"to its default setting ?" strMessage.Format(IDS_F_RESTORE_DEFAULT,(LPCTSTR)pItem->GetDescription()); answ = AfxMessageBox(strMessage , MB_ICONEXCLAMATION | MB_YESNO); if ( answ == IDYES ){ BOOL bNotUsed; pItem->SetToDefault(); pItem->SetValueModifyByUser(TRUE); if (pItem->GetType() == CaReplicationItem::REP_BOOLEAN) { CString strValue = pItem->GetFlagContent(bNotUsed); if (strValue.CompareNoCase (_T("TRUE")) == 0) m_cListCtrl.SetCheck (iIndex, 1, TRUE); else m_cListCtrl.SetCheck (iIndex, 1, FALSE); } else m_cListCtrl.SetItemText (iIndex, 1, pItem->GetFlagContent(bNotUsed)); } EnableButtons(); }
void CaReplicationItemList::VerifyValueForFlag() { POSITION pos = GetHeadPosition(); BOOL bDefault; int answ; CString Tempo,strValue,strErrorMsg,strDefault; while (pos != NULL) { CaReplicationItem* obj = GetNext(pos); Tempo = obj->GetFlagContent( bDefault ); strDefault = obj->GetDefaultValue(); if (Tempo.IsEmpty() == TRUE && ( obj->IsMandatory () || obj->IsDefaultMandatoryInFile())) { //"%s (mandatory) parameter not found in runrepl.opt. Will be set to Default." strErrorMsg.Format(IDS_F_REP_FLAG_DEFAULT,(LPCTSTR)obj->GetFlagName()); AfxMessageBox(strErrorMsg, MB_ICONEXCLAMATION | MB_OK | MB_TASKMODAL); strValue = obj->GetDefaultValue(); obj->SetFlagContent(strValue); obj->SetValueModifyByUser(TRUE); } if ( obj->IsReadOnlyFlag() && Tempo.Compare(strDefault) !=0 && ( obj->IsMandatory () || obj->IsDefaultMandatoryInFile())) { //"Inconsistent value for %s parameter.\n" //"Value in runrepl.opt file : %s\n" //"Required Value : %s\n" //"Apply required value?" strErrorMsg.Format( IDS_F_REP_FLAG_INCONSISTENT, (LPCTSTR)obj->GetDescription(), (LPCTSTR)Tempo, (LPCTSTR)strDefault); answ = AfxMessageBox(strErrorMsg, MB_ICONEXCLAMATION | MB_YESNO | MB_TASKMODAL); if ( answ == IDYES ){ strValue = obj->GetDefaultValue(); obj->SetFlagContent(strValue); obj->SetValueModifyByUser(TRUE); } else { // remove all flags in the list, no modication available. MyRemoveAll(); return; } } } }