--- a/dlls/comctl32/listview.c 2008-06-27 08:24:42.000000000 -0600 +++ b/dlls/comctl32/listview.c 2008-07-04 17:49:52.000000000 -0600 @@ -437,6 +437,7 @@ static HWND CreateEditLabelT(LISTVIEW_INFO *, LPCWSTR, DWORD, INT, INT, INT, INT, BOOL); static HIMAGELIST LISTVIEW_SetImageList(LISTVIEW_INFO *, INT, HIMAGELIST); static INT LISTVIEW_HitTest(const LISTVIEW_INFO *, LPLVHITTESTINFO, BOOL, BOOL); +static BOOL SelectAll(LISTVIEW_INFO *); /******** Text handling functions *************************************/ @@ -7510,14 +7511,27 @@ lvItem.stateMask = lpLVItem->stateMask; TRACE("lvItem=%s\n", debuglvitem_t(&lvItem, TRUE)); - if (nItem == -1) - { - /* apply to all items */ - for (lvItem.iItem = 0; lvItem.iItem < infoPtr->nItemCount; lvItem.iItem++) - if (!LISTVIEW_SetItemT(infoPtr, &lvItem, TRUE)) bResult = FALSE; - } - else - bResult = LISTVIEW_SetItemT(infoPtr, &lvItem, TRUE); + if (nItem == -1) { + /* This is the only place we can see "select all" as a whole. If it's requested, do it. */ + /* Handle all LVIS_ state attributes but CUT, since everything _can_ be cut. */ + if (LVIS_SELECTED && lvItem.stateMask && ~LVIS_CUT) { + UINT uView = infoPtr->dwStyle & LVS_TYPEMASK; + + bResult = SelectAll(infoPtr); + + /* As there's nothing else in this function to do so, redraw the list. */ + /* Fixme: SortItems doesn't redraw if the list is one of these types. Why? */ + if (uView != LVS_ICON && uView != LVS_SMALLICON) + LISTVIEW_InvalidateList(infoPtr); + } + else { + /* apply to all items */ + for (lvItem.iItem = 0; lvItem.iItem < infoPtr->nItemCount; lvItem.iItem++) + if (!LISTVIEW_SetItemT(infoPtr, &lvItem, TRUE)) bResult = FALSE; + } + } + else + bResult = LISTVIEW_SetItemT(infoPtr, &lvItem, TRUE); /* * Update selection mark @@ -7555,6 +7569,23 @@ return bResult; } +/* + * Select All Items + */ +static BOOL SelectAll(LISTVIEW_INFO *infoPtr) { + RANGE all; + + /* create the range */ + all.lower = 0; + all.upper = infoPtr->nItemCount; /* This nItemCount seems to contain the _last_index_ */ + + /* set the selection range */ + return ranges_add(infoPtr->selectionRanges, all); + + /* Done. Don't change the focussed item. */ +} + + /*** * DESCRIPTION: * Sets the text of an item or subitem.