Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
A version of this page is also available for
4/8/2010

This message sorts list-view items using an application-defined comparison function. The index of each item changes to reflect the new sequence. You can send this message explicitly or by using the ListView_SortItemsmacro.

Syntax

LVM_SORTITEMS 
wParam = (WPARAM)(LPARAM) 
lParamSort; 

lParam = (LPARAM)(PFNLVCOMPARE) 
pfnCompare;

Parameters

lParamSort

Application-defined value passed to the comparison function.

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.

Return Value

TRUE indicates success. FALSE indicates failure.

Remarks

The comparison function has the following form.

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

The lParam1parameter is the 32-bit value associated with the first item being compared, and the lParam2parameter is the value associated with the second item. These are the values specified in the lParammember of the items' LVITEMstructure when they were inserted into the list. The lParamSortparameter is the same value passed to the LVM_SORTITEMS message.

Related macro:  ListView_SortItems

Requirements

Header commctrl.h
Windows Embedded CE Windows CE 1.0 and later
Windows Mobile Windows Mobile Version 5.0 and later

See Also