views:

305

answers:

1

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?

+4  A: 

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

Tim Sylvester
This is the issue, thanks.
Zenox
Thanks. Was struggling with it for sometime. Should have tried SO first.
Jahanzeb Farooq