Sorting CListCtrl

  • Thread starter Thread starter Zebedee6
  • Start date Start date
Z

Zebedee6

Guest
Hi

Was wondering if anybody could tell me how to pass an interger variable to the below SortFunc I want to be able to change the

0 in


strItem1 = pListCtrl->GetItemText((lParam1), 0);

So I can sort on other columns

The SortFunc is defined in the the header as int static callback

Thank you




m_Sort_LstCtrl.SortItemsEx(SortFunc, (LPARAM)&m_Sort_LstCtrl);


/////////////////////////////////////////////////////////////////////////////////////////////////////
int CALLBACK CSortDlg::SortFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
{
// To sort strings
CListCtrl* pListCtrl = (CListCtrl*)lParamSort;
CString strItem1 = pListCtrl->GetItemText((lParam1), 0);
CString strItem2 = pListCtrl->GetItemText((lParam2), 0);

int result = 0;

if (strItem1.Compare(strItem2) < 0)
result = -1;
else if (strItem1.Compare(strItem2) == 0)
result = 0;
else
result = 1;

return result;

}

Continue reading...
 
Back
Top