hi,
I'm trying to sort the items in a CListCtrl.
I followed the instructions of the MSDN documention.
I wrote a callback function
static int CALLBACK MyCompareProc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
{
CListCtrl* pListCtrl = (CListCtrl*) lParamSort;
CString strItem1 = pListCtrl->GetItemText(lParam1, 0);
CString strItem2 = pListCtrl->GetItemText(lParam2, 0);
return strcmp(strItem2, strItem1);
}
in my OnInitDialog I inserted the items in the list and set the ItemData for each item (equal to the index). And then called the SortItem function as follows
m_list.SortItems(MyCompareProc, (LPARAM) &m_list);
The items were all sorted correctly,
However if I call the SortItem again the rows are shuffled. Why is that?
Shouldn't it give the same result no matter how many times I call it??
What's going on?
thanks in advance for your help
I'm trying to sort the items in a CListCtrl.
I followed the instructions of the MSDN documention.
I wrote a callback function
static int CALLBACK MyCompareProc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
{
CListCtrl* pListCtrl = (CListCtrl*) lParamSort;
CString strItem1 = pListCtrl->GetItemText(lParam1, 0);
CString strItem2 = pListCtrl->GetItemText(lParam2, 0);
return strcmp(strItem2, strItem1);
}
in my OnInitDialog I inserted the items in the list and set the ItemData for each item (equal to the index). And then called the SortItem function as follows
m_list.SortItems(MyCompareProc, (LPARAM) &m_list);
The items were all sorted correctly,
However if I call the SortItem again the rows are shuffled. Why is that?
Shouldn't it give the same result no matter how many times I call it??
What's going on?
thanks in advance for your help