bool CCampaignData::Save(CString pathName) { FitIniFile fitFile; int32_t result = fitFile.create(pathName.GetBuffer(0)); if(result != NO_ERROR) { return false; } fitFile.writeBlock("Campaign"); fitFile.writeIdBoolean("NameUseResourceString", m_NameUseResourceString); if(!m_NameUseResourceString) { fitFile.writeIdString("CampaignName", m_Name.GetBuffer(0)); } else { fitFile.writeIdLong("NameID", m_NameResourceStringID); } fitFile.writeIdLong("CBills", m_CBills); fitFile.writeIdString("FinalVideo", m_FinalVideo.GetBuffer(0)); fitFile.writeIdLong("GroupCount", m_GroupList.Count()); CGroupList::EIterator it; int32_t index; for(it = m_GroupList.Begin(), index = 0; !it.IsDone(); it++, index += 1) { ECharString blockName; blockName.Format("Group%d", index); fitFile.writeBlock(blockName.Data()); (*it).Save(fitFile, blockName.Data()); } fitFile.close(); return true; }
void CCampaignDialog::OnCaRemoveButton() { int selectedItemIndex = m_GroupListControl.GetCurSel(); if ((0 <= selectedItemIndex) && ((int)m_CampaignData.m_GroupList.Count() > selectedItemIndex)) { // should put up confirmation box here CGroupList::EIterator it = m_CampaignData.m_GroupList.Begin(); int index; for (index = 0; index < selectedItemIndex; index++) { it++; assert(!it.IsDone()); } m_CampaignData.m_GroupList.Delete(it); UpdateData(TRUE); int selectedItemIndex = m_GroupListControl.GetCurSel(); setGroupListBoxValues(m_GroupListControl, m_CampaignData.m_GroupList); if ((LB_ERR != selectedItemIndex) && (0 < m_GroupListControl.GetCount())) { if (m_GroupListControl.GetCount() <= (long)selectedItemIndex) { selectedItemIndex = m_GroupListControl.GetCount() - 1; } m_GroupListControl.SetCurSel(selectedItemIndex); } UpdateData(FALSE); } }