Small cleanups this time, inspired by Rein Klazes... ChangeLog Remove some more superfluous ZeroMemory calls, small cleanups. --- dlls/comctl32/listview.c.E0 Sat Sep 21 10:51:15 2002 +++ dlls/comctl32/listview.c Sun Sep 22 11:45:03 2002 @@ -946,7 +946,6 @@ if (lStyle & LVS_NOSCROLL) return; - ZeroMemory(&scrollInfo, sizeof(SCROLLINFO)); scrollInfo.cbSize = sizeof(SCROLLINFO); if (uView == LVS_LIST) @@ -958,7 +957,8 @@ TRACE("items=%d, perColumn=%d, perRow=%d\n", nNumOfItems, nCountPerColumn, nCountPerRow); - + + scrollInfo.nMin = 0; scrollInfo.nMax = nNumOfItems / nCountPerColumn; if((nNumOfItems % nCountPerColumn) == 0) scrollInfo.nMax--; @@ -987,15 +987,16 @@ /* update horizontal scrollbar */ nListWidth = infoPtr->rcList.right - infoPtr->rcList.left; - if (GetScrollInfo(infoPtr->hwndSelf, SB_HORZ, &scrollInfo) == FALSE + scrollInfo.fMask = SIF_POS; + if (!GetScrollInfo(infoPtr->hwndSelf, SB_HORZ, &scrollInfo) || GETITEMCOUNT(infoPtr) == 0) { scrollInfo.nPos = 0; } scrollInfo.nMin = 0; - scrollInfo.fMask = SIF_RANGE | SIF_POS | SIF_PAGE ; - scrollInfo.nPage = nListWidth; scrollInfo.nMax = max(infoPtr->nItemWidth, 0)-1; + scrollInfo.nPage = nListWidth; + scrollInfo.fMask = SIF_RANGE | SIF_POS | SIF_PAGE ; test = (scrollInfo.nMin >= scrollInfo.nMax - max((INT)scrollInfo.nPage - 1, 0)); TRACE("LVS_REPORT Horz. nMax=%d, nPage=%d, test=%d\n", scrollInfo.nMax, scrollInfo.nPage, test); @@ -1019,13 +1020,13 @@ /* Update Horizontal Scrollbar */ scrollInfo.fMask = SIF_POS; - if (GetScrollInfo(infoPtr->hwndSelf, SB_HORZ, &scrollInfo) == FALSE + if (!GetScrollInfo(infoPtr->hwndSelf, SB_HORZ, &scrollInfo) || GETITEMCOUNT(infoPtr) == 0) { scrollInfo.nPos = 0; } - scrollInfo.nMax = max(nViewWidth, 0)-1; scrollInfo.nMin = 0; + scrollInfo.nMax = max(nViewWidth, 0)-1; scrollInfo.nPage = nListWidth; scrollInfo.fMask = SIF_RANGE | SIF_POS | SIF_PAGE; TRACE("LVS_ICON/SMALLICON Horz.\n"); @@ -1034,13 +1035,13 @@ /* Update Vertical Scrollbar */ nListHeight = infoPtr->rcList.bottom - infoPtr->rcList.top; scrollInfo.fMask = SIF_POS; - if (GetScrollInfo(infoPtr->hwndSelf, SB_VERT, &scrollInfo) == FALSE + if (GetScrollInfo(infoPtr->hwndSelf, SB_VERT, &scrollInfo) || GETITEMCOUNT(infoPtr) == 0) { scrollInfo.nPos = 0; } - scrollInfo.nMax = max(nViewHeight,0)-1; scrollInfo.nMin = 0; + scrollInfo.nMax = max(nViewHeight,0)-1; scrollInfo.nPage = nListHeight; scrollInfo.fMask = SIF_RANGE | SIF_POS | SIF_PAGE; TRACE("LVS_ICON/SMALLICON Vert.\n"); @@ -2490,7 +2491,6 @@ INT nItem = 0; SCROLLINFO scrollInfo; - ZeroMemory(&scrollInfo, sizeof(SCROLLINFO)); scrollInfo.cbSize = sizeof(SCROLLINFO); scrollInfo.fMask = SIF_POS; @@ -4007,7 +4007,6 @@ RECT rcItem; BOOL bRedraw = FALSE; - ZeroMemory(&scrollInfo, sizeof(SCROLLINFO)); scrollInfo.cbSize = sizeof(SCROLLINFO); scrollInfo.fMask = SIF_POS; @@ -4210,6 +4209,7 @@ if ((nItem >= -1) && (lpFindInfo != NULL)) { + lvItem.mask = 0; if (lpFindInfo->flags & LVFI_PARAM) { lvItem.mask |= LVIF_PARAM; @@ -4841,7 +4841,6 @@ { SCROLLINFO scrollInfo; /* Adjust position by scrollbar offset */ - ZeroMemory(&scrollInfo, sizeof(SCROLLINFO)); scrollInfo.cbSize = sizeof(SCROLLINFO); scrollInfo.fMask = SIF_POS; GetScrollInfo(infoPtr->hwndSelf, SB_HORZ, &scrollInfo); @@ -5805,7 +5804,6 @@ if (!lpptOrigin) return FALSE; - ZeroMemory(&scrollInfo, sizeof(SCROLLINFO)); scrollInfo.cbSize = sizeof(SCROLLINFO); scrollInfo.fMask = SIF_POS; @@ -5876,22 +5874,23 @@ */ static LRESULT LISTVIEW_GetStringWidthT(LISTVIEW_INFO *infoPtr, LPCWSTR lpszText, BOOL isW) { - if (is_textT(lpszText, isW)) - { - HFONT hFont = infoPtr->hFont ? infoPtr->hFont : infoPtr->hDefaultFont; - HDC hdc = GetDC(infoPtr->hwndSelf); - HFONT hOldFont = SelectObject(hdc, hFont); SIZE stringSize; - ZeroMemory(&stringSize, sizeof(SIZE)); - if (isW) - GetTextExtentPointW(hdc, lpszText, lstrlenW(lpszText), &stringSize); - else - GetTextExtentPointA(hdc, (LPCSTR)lpszText, lstrlenA((LPCSTR)lpszText), &stringSize); - SelectObject(hdc, hOldFont); - ReleaseDC(infoPtr->hwndSelf, hdc); + + stringSize.cx = 0; + if (is_textT(lpszText, isW)) + { + HFONT hFont = infoPtr->hFont ? infoPtr->hFont : infoPtr->hDefaultFont; + HDC hdc = GetDC(infoPtr->hwndSelf); + HFONT hOldFont = SelectObject(hdc, hFont); + + if (isW) + GetTextExtentPointW(hdc, lpszText, lstrlenW(lpszText), &stringSize); + else + GetTextExtentPointA(hdc, (LPCSTR)lpszText, lstrlenA((LPCSTR)lpszText), &stringSize); + SelectObject(hdc, hOldFont); + ReleaseDC(infoPtr->hwndSelf, hdc); + } return stringSize.cx; - } - return 0; } /*** @@ -7627,7 +7626,6 @@ SendMessageW(infoPtr->hwndEdit, WM_KILLFOCUS, 0, 0); - ZeroMemory(&scrollInfo, sizeof(SCROLLINFO)); scrollInfo.cbSize = sizeof(SCROLLINFO); scrollInfo.fMask = SIF_PAGE | SIF_POS | SIF_RANGE | SIF_TRACKPOS; @@ -7731,7 +7729,6 @@ SendMessageW(infoPtr->hwndEdit, WM_KILLFOCUS, 0, 0); - ZeroMemory(&scrollInfo, sizeof(SCROLLINFO)); scrollInfo.cbSize = sizeof(SCROLLINFO); scrollInfo.fMask = SIF_PAGE | SIF_POS | SIF_RANGE | SIF_TRACKPOS; @@ -7817,9 +7814,8 @@ SystemParametersInfoW(SPI_GETWHEELSCROLLLINES,0, &pulScrollLines, 0); gcWheelDelta -= wheelDelta; - ZeroMemory(&scrollInfo, sizeof(SCROLLINFO)); scrollInfo.cbSize = sizeof(SCROLLINFO); - scrollInfo.fMask = SIF_POS | SIF_RANGE; + scrollInfo.fMask = SIF_POS; switch(uView) {