Click here to Skip to main content
15,913,685 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Design question Pin
alex.barylski27-Oct-03 6:55
alex.barylski27-Oct-03 6:55 
GeneralCListCtrl DeleteItem Pin
Jarek G26-Oct-03 13:05
Jarek G26-Oct-03 13:05 
GeneralRe: CListCtrl DeleteItem Pin
Daniel132426-Oct-03 13:53
Daniel132426-Oct-03 13:53 
GeneralRe: CListCtrl DeleteItem Pin
Ravi Bhavnani26-Oct-03 13:54
professionalRavi Bhavnani26-Oct-03 13:54 
GeneralRe: CListCtrl DeleteItem Pin
Jarek G26-Oct-03 14:16
Jarek G26-Oct-03 14:16 
GeneralRe: CListCtrl DeleteItem Pin
Ravi Bhavnani26-Oct-03 14:39
professionalRavi Bhavnani26-Oct-03 14:39 
GeneralRe: CListCtrl DeleteItem Pin
Jarek G26-Oct-03 23:32
Jarek G26-Oct-03 23:32 
GeneralRe: CListCtrl DeleteItem Pin
Roger Allen27-Oct-03 2:21
Roger Allen27-Oct-03 2:21 
You have to iterate the list first to get all the selected items positions. Once you have that list go through it backwards to delete all the indexes as deleting them in the order you receive them changes the indexes of the following items.

int count = m_UsingList.GetSelectedCount();

// Get the list of selected items and remove them
if (count > 0)
{
    int *pIndexes = new int[count];
    int index = 0;

    POSITION pos = m_UsingList.GetFirstSelectedItemPosition();
    while (pos)
    {
        pIndexes[index++] = m_UsingList.GetNextSelectedItem(pos);
    }
    // we have to remove the items from the list in reverse order
    // as removing one before a later index changes the order!
    for (index = count - 1 ; index >= 0 ; index--)
    {
        m_UsingList.DeleteItem(pIndexes[index]);
    }
    delete []pIndexes;
    pIndexes = NULL;
    // done!
}



Roger Allen
Sonork 100.10016

Death come early, death come late,
It takes us all, there is no reason.
For every purpose under heaven,
To each a turn, to each a season.
A time to weep and a time to sigh,
A time to laugh and a time to cry,
A time to be born and a time to die.
Dust to dust and ashes to ashes,
And so I end my song.

GeneralRe: CListCtrl DeleteItem Pin
David Crow27-Oct-03 4:46
David Crow27-Oct-03 4:46 
GeneralRe: CListCtrl DeleteItem Pin
Jarek G27-Oct-03 7:59
Jarek G27-Oct-03 7:59 
GeneralRe: CListCtrl DeleteItem Pin
Abin27-Oct-03 14:09
Abin27-Oct-03 14:09 
GeneralCPP question Pin
alex.barylski26-Oct-03 12:22
alex.barylski26-Oct-03 12:22 
GeneralRe: CPP question Pin
Steve S27-Oct-03 1:46
Steve S27-Oct-03 1:46 
GeneralRe: CPP question Pin
alex.barylski27-Oct-03 6:53
alex.barylski27-Oct-03 6:53 
GeneralRe: CPP question Pin
Roger Allen27-Oct-03 2:32
Roger Allen27-Oct-03 2:32 
GeneralRe: CPP question Pin
Steve S27-Oct-03 3:20
Steve S27-Oct-03 3:20 
GeneralRestore Window State; Pin
Bo Hunter26-Oct-03 11:46
Bo Hunter26-Oct-03 11:46 
GeneralRe: Restore Window State; Pin
Ravi Bhavnani26-Oct-03 12:25
professionalRavi Bhavnani26-Oct-03 12:25 
GeneralGetOpenFileName Pin
Anonymous26-Oct-03 11:45
Anonymous26-Oct-03 11:45 
GeneralRe: GetOpenFileName Pin
Ravi Bhavnani26-Oct-03 12:27
professionalRavi Bhavnani26-Oct-03 12:27 
GeneralRe: GetOpenFileName Pin
georgiek5026-Oct-03 13:33
georgiek5026-Oct-03 13:33 
GeneralRe: GetOpenFileName Pin
Ravi Bhavnani26-Oct-03 13:51
professionalRavi Bhavnani26-Oct-03 13:51 
GeneralRe: GetOpenFileName Pin
georgiek5026-Oct-03 14:02
georgiek5026-Oct-03 14:02 
GeneralRe: GetOpenFileName Pin
Ravi Bhavnani26-Oct-03 14:29
professionalRavi Bhavnani26-Oct-03 14:29 
QuestionHow do I increment a char? Pin
JasonKaiser26-Oct-03 11:43
JasonKaiser26-Oct-03 11:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.