Sorting a listview (Win32/C++)

c++, listview, winapi

Solution

Are you using the `LVS_OWNERDATA` style on your control?

There are a number of features incompatible with that style, including sorting:

http://msdn.microsoft.com/en-us/library/bb774735%28VS.85%29.aspx

Problem

I'm trying to sort a listview when the user clicks on the column header. I am catching the LVN_COLUMNCLICK notification like so: ``` case LVN_COLUMNCLICK: { NMLISTVIEW* pListView = (NMLISTVIEW*)lParam; BOOL test = ListView_SortItems ( m_hDuplicateObjectsList, ListViewCompareProc, pListView->iSubItem ); break; } ``` However it seems to fail. My test variable is FALSE and my ListViewCompareProc never gets hit (it has a simple return 1 while I am trying to hit a debug point inside of it). Is there something I am missing for sorting a listview?

Original source