0

i have a function which loops through map (the map contains the index of my CTabCtrl-Tab and the ID of the Document which is shown in the Tab) and if the ID of the current selected Tab is not similar to the ID of the current looped tab, the tab should be removed.

int deleteTab = -1;

for (auto i : tabIndexToFBNR)
{
    deleteTab = i.first;

    if (i.second == m_pDlgSubFBs.at(m_AktTab)->m_pRecFB->m_ID)
        deleteTab = -1;

    if (deleteTab != -1)
        m_tabSubFB.DeleteItem(deleteTab);
}

Problem is: Some tabs are removed, some are not. The return code of DeleteItem is always "1".

Any ideas?

Orothred
  • 11
  • 2
  • Too little information to help. My guess is: You iterate forward through your mappings, but then delete stuff in the middle. Entries are moved down one notch. When you advance to the next iteration, you skip the entry that has taken the deleted entry's place. – j6t May 07 '20 at 09:11
  • I guess you´re right :D Thank you :-) – Orothred May 07 '20 at 09:34

0 Answers0