对这个不是太熟,但是MSDN中LVM_SORTITEMS 的解释有这么一段:Note During the sorting process, the list-view contents are unstable. If the callback function sends any messages to the list-view control aside from LVM_GETITEM (ListView_GetItem), the results are unpredictable.
SortItems前加 int i = GetItemCount(); for (int k=0;k<i;k++) { SetItemData(k,k); }
int i = GetItemCount();
for (int k=0;k<i;k++)
{
SetItemData(k,k);
}