[COMCTL32] Sync with Wine Staging 2.9. CORE-13362
[reactos.git] / reactos / dll / win32 / comctl32 / pager.c
index d4fbd39..3004435 100644 (file)
@@ -239,10 +239,9 @@ PAGER_PositionChildWnd(PAGER_INFO* infoPtr)
             TRACE("[%p] SWP %dx%d at (%d,%d)\n", infoPtr->hwndSelf,
                          infoPtr->nWidth, infoPtr->nHeight,
                          -nPos, 0);
-            SetWindowPos(infoPtr->hwndChild, 0,
+            SetWindowPos(infoPtr->hwndChild, HWND_TOP,
                          -nPos, 0,
-                         infoPtr->nWidth, infoPtr->nHeight,
-                         SWP_NOZORDER);
+                         infoPtr->nWidth, infoPtr->nHeight, 0);
         }
         else
         {
@@ -253,10 +252,9 @@ PAGER_PositionChildWnd(PAGER_INFO* infoPtr)
             TRACE("[%p] SWP %dx%d at (%d,%d)\n", infoPtr->hwndSelf,
                          infoPtr->nWidth, infoPtr->nHeight,
                          0, -nPos);
-            SetWindowPos(infoPtr->hwndChild, 0,
+            SetWindowPos(infoPtr->hwndChild, HWND_TOP,
                          0, -nPos,
-                         infoPtr->nWidth, infoPtr->nHeight,
-                         SWP_NOZORDER);
+                         infoPtr->nWidth, infoPtr->nHeight, 0);
         }
 
         InvalidateRect(infoPtr->hwndChild, NULL, TRUE);
@@ -264,7 +262,7 @@ PAGER_PositionChildWnd(PAGER_INFO* infoPtr)
 }
 
 static INT
-PAGER_GetScrollRange(PAGER_INFO* infoPtr)
+PAGER_GetScrollRange(PAGER_INFO* infoPtr, BOOL calc_size)
 {
     INT scrollRange = 0;
 
@@ -274,7 +272,8 @@ PAGER_GetScrollRange(PAGER_INFO* infoPtr)
         RECT wndRect;
         GetWindowRect(infoPtr->hwndSelf, &wndRect);
 
-        PAGER_CalcSize(infoPtr);
+        if (calc_size)
+            PAGER_CalcSize(infoPtr);
         if (infoPtr->dwStyle & PGS_HORZ)
         {
             wndSize = wndRect.right - wndRect.left;
@@ -355,9 +354,9 @@ PAGER_UpdateBtns(PAGER_INFO *infoPtr, INT scrollRange, BOOL hideGrayBtns)
 }
 
 static LRESULT
-PAGER_SetPos(PAGER_INFO* infoPtr, INT newPos, BOOL fromBtnPress)
+PAGER_SetPos(PAGER_INFO* infoPtr, INT newPos, BOOL fromBtnPress, BOOL calc_size)
 {
-    INT scrollRange = PAGER_GetScrollRange(infoPtr);
+    INT scrollRange = PAGER_GetScrollRange(infoPtr, calc_size);
     INT oldPos = infoPtr->nPos;
 
     if ((scrollRange <= 0) || (newPos < 0))
@@ -398,12 +397,12 @@ PAGER_RecalcSize(PAGER_INFO *infoPtr)
 
     if (infoPtr->hwndChild)
     {
-        INT scrollRange = PAGER_GetScrollRange(infoPtr);
+        INT scrollRange = PAGER_GetScrollRange(infoPtr, TRUE);
 
         if (scrollRange <= 0)
         {
             infoPtr->nPos = -1;
-            PAGER_SetPos(infoPtr, 0, FALSE);
+            PAGER_SetPos(infoPtr, 0, FALSE, TRUE);
         }
         else
             PAGER_PositionChildWnd(infoPtr);
@@ -472,13 +471,8 @@ PAGER_SetChild (PAGER_INFO* infoPtr, HWND hwndChild)
         SetWindowPos(infoPtr->hwndSelf, 0, 0, 0, 0, 0,
                      SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE);
 
-        /* position child within the page scroller */
-        SetWindowPos(infoPtr->hwndChild, HWND_TOP,
-                     0,0,0,0,
-                     SWP_SHOWWINDOW | SWP_NOSIZE);  /* native is 0 */
-
         infoPtr->nPos = -1;
-        PAGER_SetPos(infoPtr, 0, FALSE);
+        PAGER_SetPos(infoPtr, 0, FALSE, FALSE);
     }
 
     return 0;
@@ -523,9 +517,9 @@ PAGER_Scroll(PAGER_INFO* infoPtr, INT dir)
             infoPtr->direction = dir;
 
             if (dir == PGF_SCROLLLEFT || dir == PGF_SCROLLUP)
-                PAGER_SetPos(infoPtr, infoPtr->nPos - nmpgScroll.iScroll, TRUE);
+                PAGER_SetPos(infoPtr, infoPtr->nPos - nmpgScroll.iScroll, TRUE, TRUE);
             else
-                PAGER_SetPos(infoPtr, infoPtr->nPos + nmpgScroll.iScroll, TRUE);
+                PAGER_SetPos(infoPtr, infoPtr->nPos + nmpgScroll.iScroll, TRUE, TRUE);
         }
         else
             infoPtr->direction = -1;
@@ -1045,7 +1039,7 @@ PAGER_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
             return PAGER_SetChild (infoPtr, (HWND)lParam);
 
         case PGM_SETPOS:
-            return PAGER_SetPos(infoPtr, (INT)lParam, FALSE);
+            return PAGER_SetPos(infoPtr, (INT)lParam, FALSE, TRUE);
 
         case WM_CREATE:
             return PAGER_Create (hwnd, (LPCREATESTRUCTW)lParam);