Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

calling CListCtrl::SortItems() twice in a row

Status
Not open for further replies.

dima2

Programmer
Jan 20, 2002
85
LB
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

 
Hi,
Has your resource already the sort flag set ?
Is your function called by framework when Windows refreshes windows ?

bye.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top