windows_programming_notes.nbk: Home | Index | Next Page: LoadCursor | Previous Page: ListView_SortItems
Uses an application-defined comparison function to sort the items of a list-view control. The index of each item changes to reflect the new sequence. You can use this macro or send the LVM_SORTITEMSEX message explicitly.
BOOL ListView_SortItemsEx( HWND hwnd, PFNLVCOMPARE pfnCompare, LPARAM lParamSort );
Returns TRUE if successful, or FALSE otherwise.
The comparison function has the following form.
CALLBACK CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort);
where lParam1 is the index of the first item and lParam2 the index of the second. The ListView_SortItemsEx's lParamSort parameter is passed to the callback function as its third parameter.
The comparison function must return a negative value if the first item should precede the second, a positive value if the first item should follow the second, or zero if the two items are equivalent.
You can send an LVM_GETITEMTEXT message to retrieve further information on an item, if needed.
This macro is similar to ListView_SortItems, except for the type of information passed to the comparison function. With ListView_SortItemsEx, the item's index is passed instead of its lparam value.
Note: During the sorting process, the list-view contents are unstable. If the callback function sends any messages to the list-view control aside from [LVM_GETITEM] (ListView_GetItem), the results are unpredictable.
windows_programming_notes.nbk: Home | Index | Next Page: LoadCursor | Previous Page: ListView_SortItems
Notebook exported on Monday, 7 July 2008, 18:56:50 PM Eastern Daylight Time