Listview scroll updates

Dimitrie O. Paun dpaun at rogers.com
Thu Sep 12 14:02:29 CDT 2002


Some bugs were introduced in the big scroll patch,
some were in there already.

ChangeLog
  Fix a bunch of bugs related to scrolling.

Index: dlls/comctl32/listview.c
===================================================================
RCS file: /var/cvs/wine/dlls/comctl32/listview.c,v
retrieving revision 1.141
diff -u -r1.141 listview.c
--- dlls/comctl32/listview.c	12 Sep 2002 18:10:41 -0000	1.141
+++ dlls/comctl32/listview.c	12 Sep 2002 18:41:47 -0000
@@ -843,22 +843,20 @@
   if (uView == LVS_LIST)
   {
     /* update horizontal scrollbar */
-
     INT nCountPerColumn = LISTVIEW_GetCountPerColumn(infoPtr);
     INT nCountPerRow = LISTVIEW_GetCountPerRow(infoPtr);
     INT nNumOfItems = GETITEMCOUNT(infoPtr);
 
-    scrollInfo.nMax = nNumOfItems / nCountPerColumn;
     TRACE("items=%d, perColumn=%d, perRow=%d\n",
 	  nNumOfItems, nCountPerColumn, nCountPerRow);
+    
+    scrollInfo.nMax = nNumOfItems / nCountPerColumn;
     if((nNumOfItems % nCountPerColumn) == 0)
-    {
         scrollInfo.nMax--;
-    }
+    if (scrollInfo.nMax < 0) scrollInfo.nMax = 0;
     scrollInfo.nPos = ListView_GetTopIndex(infoPtr->hwndSelf) / nCountPerColumn;
     scrollInfo.nPage = nCountPerRow;
     scrollInfo.fMask = SIF_RANGE | SIF_POS | SIF_PAGE;
-    TRACE("LVS_LIST\n");
     SetScrollInfo(infoPtr->hwndSelf, SB_HORZ, &scrollInfo, TRUE);
     ShowScrollBar(infoPtr->hwndSelf, SB_VERT, FALSE);
   }
@@ -8070,13 +8068,16 @@
 	    nNewScrollPos = scrollInfo.nMin;
     }
 
-    /* carry on only if it really changed */
-    if (nNewScrollPos == nOldScrollPos) return 0;
-    
-    /* set the new position */
+    /* set the new position, and reread in case it changed */
     scrollInfo.fMask = SIF_POS;
     scrollInfo.nPos = nNewScrollPos;
     SetScrollInfo(infoPtr->hwndSelf, SB_VERT, &scrollInfo, TRUE);
+    scrollInfo.fMask = SIF_POS;
+    if (!GetScrollInfo(infoPtr->hwndSelf, SB_VERT, &scrollInfo)) return 1;
+    nNewScrollPos = scrollInfo.nPos;
+    
+    /* carry on only if it really changed */
+    if (nNewScrollPos == nOldScrollPos) return 0;
     
     /* now adjust to client coordinates */
     nScrollDiff = nOldScrollPos - nNewScrollPos;
@@ -8153,6 +8154,7 @@
     case SB_THUMBPOSITION:
     case SB_THUMBTRACK:
 	nScrollDiff = scrollInfo.nTrackPos - scrollInfo.nPos;
+	break;
 
     default:
 	nScrollDiff = 0;
@@ -8173,20 +8175,23 @@
 	    nNewScrollPos = scrollInfo.nMin;
     }
 
-    /* carry on only if it really changed */
-    if (nNewScrollPos == nOldScrollPos) return 0;
-    
-    /* set the new position */
+    /* set the new position, and reread in case it changed */
     scrollInfo.fMask = SIF_POS;
     scrollInfo.nPos = nNewScrollPos;
-    SetScrollInfo(infoPtr->hwndSelf, SB_VERT, &scrollInfo, TRUE);
+    SetScrollInfo(infoPtr->hwndSelf, SB_HORZ, &scrollInfo, TRUE);
+    scrollInfo.fMask = SIF_POS;
+    if (!GetScrollInfo(infoPtr->hwndSelf, SB_HORZ, &scrollInfo)) return 1;
+    nNewScrollPos = scrollInfo.nPos;
+    
+    /* carry on only if it really changed */
+    if (nNewScrollPos == nOldScrollPos) return 0;
     
-      if(uView == LVS_REPORT)
-          LISTVIEW_UpdateHeaderSize(infoPtr, nNewScrollPos);
+    if(uView == LVS_REPORT)
+        LISTVIEW_UpdateHeaderSize(infoPtr, nNewScrollPos);
       
     /* now adjust to client coordinates */
     nScrollDiff = nOldScrollPos - nNewScrollPos;
-    if (uView == LVS_REPORT) nScrollDiff *= infoPtr->nItemHeight;
+    if (uView == LVS_LIST) nScrollDiff *= infoPtr->nItemWidth;
    
     /* and scroll the window */ 
     ScrollWindowEx( infoPtr->hwndSelf, nScrollDiff, 0, &infoPtr->rcList,




More information about the wine-patches mailing list