This should fix a FTP Commander bug reported by Carlos. ChangeLog Delay some size computations until after first paint. --- dlls/comctl32/listview.c.W7 Wed Oct 23 12:00:09 2002 +++ dlls/comctl32/listview.c Wed Oct 23 12:14:16 2002 @@ -54,6 +54,7 @@ * * Speedups * -- LISTVIEW_SetItemCount is too invalidation happy + * -- LISTVIEW_Size invalidates too much * -- in sorted mode, LISTVIEW_InsertItemT sorts the array, * instead of inserting in the right spot * -- we should keep an ordered array of coordinates in iconic mode @@ -250,6 +251,7 @@ BOOL bFocus; INT nFocusedItem; RECT rcFocus; + BOOL bFirstPaint; /* Flags if the control has never painted before */ DWORD dwStyle; /* the cached window GWL_STYLE */ DWORD dwLvExStyle; /* extended listview style */ INT nItemCount; /* the number of items in the list */ @@ -6896,6 +6898,7 @@ infoPtr->iconSpacing.cx = GetSystemMetrics(SM_CXICONSPACING); infoPtr->iconSpacing.cy = GetSystemMetrics(SM_CYICONSPACING); infoPtr->nEditLabelItem = -1; + infoPtr->bFirstPaint = TRUE; /* get default font (icon title) */ SystemParametersInfoW(SPI_GETICONTITLELOGFONT, 0, &logFont, 0); @@ -6956,9 +6959,6 @@ infoPtr->hdpaPosX = DPA_Create(10); infoPtr->hdpaPosY = DPA_Create(10); - /* initialize size of items */ - LISTVIEW_UpdateItemSize(infoPtr); - /* initialize the hover time to -1(indicating the default system hover time) */ infoPtr->dwHoverTime = -1; @@ -7705,6 +7705,16 @@ { TRACE("(hdc=%p)\n", hdc); + if (infoPtr->bFirstPaint) + { + UINT uView = infoPtr->dwStyle & LVS_TYPEMASK; + + LISTVIEW_UpdateItemSize(infoPtr); + if (uView == LVS_ICON || uView == LVS_SMALLICON) + LISTVIEW_Arrange(infoPtr, LVA_DEFAULT); + LISTVIEW_UpdateScroll(infoPtr); + infoPtr->bFirstPaint = FALSE; + } if (hdc) LISTVIEW_Refresh(infoPtr, hdc); else @@ -7982,7 +7992,7 @@ LISTVIEW_UpdateScroll(infoPtr); - LISTVIEW_InvalidateList(infoPtr); + LISTVIEW_InvalidateList(infoPtr); /* FIXME: optimize */ return 0; }