I've tried several approaches, but none of them seem to work...
Here's my latest code for this.. Someone please help!
From my windowproc's WM_NOTIFY:
My integer sort function. Both lParam1 & 2 are 0 when i click a columnheader...What's happening here??Code:case LVN_COLUMNCLICK: // Keep track of sort order and column used for sorting. static int nSortColumn = -1; static BOOL bSortAscending = TRUE; LVITEM lvi; // Reverse sort order if column was just previously clicked. if(((NM_LISTVIEW*)lParam)->iSubItem == nSortColumn) bSortAscending = !bSortAscending; else{ bSortAscending = TRUE; nSortColumn = ((NM_LISTVIEW*)lParam)->iSubItem; } // Set item data for each row to column value, // since sort routine gets passed item data only. for(int item=0; item<ListView_GetItemCount(GetDlgItem(hwThis, LIST1)); item++){ ListView_GetItem(GetDlgItem(hwThis, LIST1), &lvi); int value = GetLstItemLong(GetDlgItem(hwThis, LIST1), item, ((NM_LISTVIEW*)lParam)->iSubItem); // numeric sort if(!bSortAscending) { value = -value; } lvi.lParam = (long)&value; ListView_SetItem(GetDlgItem(hwThis, LIST1), &lvi); } LPARAM lParamSort = 0; ListView_SortItems(GetDlgItem(hwThis, LIST1), CompareFunc, lParamSort); break;
Code:int CALLBACK CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort){ // First two parameters are item data to be compared. // Third parameter is passed from SortItems, not used here. if (lParam1 < lParam2) {return -1;} if (lParam1 > lParam2) {return 1;} return 0; }



LinkBack URL
About LinkBacks


