Share via


ListView_SortItems

This macro 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 );

Parameters

  • hwnd
    Handle to the list view control.
  • pfnCompare
    Pointer to the application-defined comparison function. The comparison function is called during the sort operation each time the relative order of two list items needs to be compared.
  • lParamSort
    Application-defined value that is passed to the comparison function.

Return Values

TRUE indicates success. FALSE indicates failure.

Remarks

The comparison function has the following form:

int CALLBACK CompareFunc(LPARAM lParam1, LPARAM lParam2, 
LPARAM lParamSort); 
 

The lParam1 parameter is the 32-bit 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.

Related message: LVM_SORTITEMS

Requirements

Runs on Versions Defined in Include Link to
Windows CE OS 1.0 and later Commctrl.h    

Note   This API is part of the complete Windows CE OS package as provided by Microsoft. The functionality of a particular platform is determined by the original equipment manufacturer (OEM) and some devices may not support this API.

 Last updated on Tuesday, July 13, 2004

© 1992-2000 Microsoft Corporation. All rights reserved.