comctl32: LISTVIEW_InsertItemT should accept iItem < 0, when using sorted lists.

This commit is contained in:
Peter Åstrand 2006-03-07 14:07:49 +01:00 committed by Alexandre Julliard
parent 1d491aedba
commit c5552a694b
1 changed files with 3 additions and 1 deletions

View File

@ -6211,7 +6211,7 @@ static INT LISTVIEW_InsertItemT(LISTVIEW_INFO *infoPtr, const LVITEMW *lpLVItem,
if (infoPtr->dwStyle & LVS_OWNERDATA) return infoPtr->nItemCount++;
/* make sure it's an item, and not a subitem; cannot insert a subitem */
if (!lpLVItem || lpLVItem->iItem < 0 || lpLVItem->iSubItem) return -1;
if (!lpLVItem || lpLVItem->iSubItem) return -1;
if (!is_assignable_item(lpLVItem, infoPtr->dwStyle)) return -1;
@ -6224,6 +6224,8 @@ static INT LISTVIEW_InsertItemT(LISTVIEW_INFO *infoPtr, const LVITEMW *lpLVItem,
is_sorted = (infoPtr->dwStyle & (LVS_SORTASCENDING | LVS_SORTDESCENDING)) &&
!(infoPtr->dwStyle & LVS_OWNERDRAWFIXED) && (LPSTR_TEXTCALLBACKW != lpLVItem->pszText);
if (lpLVItem->iItem < 0 && !is_sorted) return -1;
nItem = is_sorted ? infoPtr->nItemCount : min(lpLVItem->iItem, infoPtr->nItemCount);
TRACE(" inserting at %d, sorted=%d, count=%d, iItem=%d\n", nItem, is_sorted, infoPtr->nItemCount, lpLVItem->iItem);
nItem = DPA_InsertPtr( infoPtr->hdpaItems, nItem, hdpaSubItems );