windows_programming_notes.nbk: Home | Index | Next Page: ListView_SortItemsEx | Previous Page: ListView_GetItem
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_SORTITEMS message explicitly.
BOOL ListView_SortItems( 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);
The lParam1 parameter is the value associated with the first item being compared; and the lParam2 parameter is the value associated with the second item. These are the values that were specified in the lParam member of the items' LVITEM structure when they were inserted into the list. The lParamSort parameter is the same value passed to the LVM_SORTITEMS message.
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.
Note: During the sorting process, the list-view contents are unstable. If the callback function sends any messages to the list-view control, the results are unpredictable.
See also ListView_SortItemsEx
windows_programming_notes.nbk: Home | Index | Next Page: ListView_SortItemsEx | Previous Page: ListView_GetItem
Notebook exported on Monday, 7 July 2008, 18:56:50 PM Eastern Daylight Time