Jacek Caban : user32: Allow scrollbar control to store scroll info in subclassed window.

Alexandre Julliard julliard at winehq.org
Wed Nov 7 14:47:32 CST 2018


Module: wine
Branch: master
Commit: 8c8701befb785b93a1ca6e42241f0b112ffd7069
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=8c8701befb785b93a1ca6e42241f0b112ffd7069

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Tue Nov  6 13:31:22 2018 +0100

user32: Allow scrollbar control to store scroll info in subclassed window.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=46004
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=45966
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/user32/scroll.c       | 35 +++++++++++++++++++++++++++++------
 dlls/user32/tests/scroll.c |  1 -
 2 files changed, 29 insertions(+), 7 deletions(-)

diff --git a/dlls/user32/scroll.c b/dlls/user32/scroll.c
index 30a0cd9..37095df 100644
--- a/dlls/user32/scroll.c
+++ b/dlls/user32/scroll.c
@@ -50,6 +50,14 @@ typedef struct
     SCROLLBAR_INFO vert;
 } WINSCROLLBAR_INFO, *LPWINSCROLLBAR_INFO;
 
+typedef struct
+{
+    DWORD magic;
+    SCROLLBAR_INFO info;
+} SCROLLBAR_WNDDATA;
+
+#define SCROLLBAR_MAGIC 0x5c6011ba
+
   /* Minimum size of the rectangle between the arrows */
 #define SCROLL_MIN_RECT  4
 
@@ -118,7 +126,7 @@ const struct builtin_class_descr SCROLL_builtin_class =
     scrollbarW,             /* name */
     CS_DBLCLKS | CS_VREDRAW | CS_HREDRAW | CS_PARENTDC, /* style  */
     WINPROC_SCROLLBAR,      /* proc */
-    sizeof(SCROLLBAR_INFO), /* extra */
+    sizeof(SCROLLBAR_WNDDATA), /* extra */
     IDC_ARROW,              /* cursor */
     0                       /* brush */
 };
@@ -159,8 +167,13 @@ static SCROLLBAR_INFO *SCROLL_GetInternalInfo( HWND hwnd, INT nBar, BOOL alloc )
             if (wndPtr->pScroll) infoPtr = &((LPWINSCROLLBAR_INFO)wndPtr->pScroll)->vert;
             break;
         case SB_CTL:
-            if (get_class_winproc( wndPtr->class ) == BUILTIN_WINPROC( WINPROC_SCROLLBAR ))
-                infoPtr = (SCROLLBAR_INFO *)wndPtr->wExtra;
+            if (wndPtr->cbWndExtra >= sizeof(SCROLLBAR_WNDDATA))
+            {
+                SCROLLBAR_WNDDATA *data = (SCROLLBAR_WNDDATA*)wndPtr->wExtra;
+                if (data->magic == SCROLLBAR_MAGIC)
+                    infoPtr = &data->info;
+            }
+            if (!infoPtr) WARN("window is not a scrollbar control\n");
             break;
         case SB_BOTH:
             WARN("with SB_BOTH\n");
@@ -1131,18 +1144,28 @@ void SCROLL_TrackScrollBar( HWND hwnd, INT scrollbar, POINT pt )
  */
 static void SCROLL_CreateScrollBar(HWND hwnd, LPCREATESTRUCTW lpCreate)
 {
-    LPSCROLLBAR_INFO info = SCROLL_GetInternalInfo(hwnd, SB_CTL, TRUE);
-    if (!info) return;
+    LPSCROLLBAR_INFO info = NULL;
+    WND *win;
 
     TRACE("hwnd=%p lpCreate=%p\n", hwnd, lpCreate);
 
+    win = WIN_GetPtr(hwnd);
+    if (win->cbWndExtra >= sizeof(SCROLLBAR_WNDDATA))
+    {
+        SCROLLBAR_WNDDATA *data = (SCROLLBAR_WNDDATA*)win->wExtra;
+        data->magic = SCROLLBAR_MAGIC;
+        info = &data->info;
+    }
+    else WARN("Not enough extra data\n");
+    WIN_ReleasePtr(win);
+    if (!info) return;
+
     if (lpCreate->style & WS_DISABLED)
     {
         info->flags = ESB_DISABLE_BOTH;
         TRACE("Created WS_DISABLED scrollbar\n");
     }
 
-
     if (lpCreate->style & (SBS_SIZEGRIP | SBS_SIZEBOX))
     {
         if (lpCreate->style & SBS_SIZEBOXTOPLEFTALIGN)
diff --git a/dlls/user32/tests/scroll.c b/dlls/user32/tests/scroll.c
index 1ff9b39..43d4720 100644
--- a/dlls/user32/tests/scroll.c
+++ b/dlls/user32/tests/scroll.c
@@ -640,7 +640,6 @@ static void test_subclass(void)
     memset(&scroll_info, 0xcc, sizeof(scroll_info));
     scroll_info.cbSize = sizeof(scroll_info);
     res = SendMessageA(hwnd, SBM_GETSCROLLBARINFO, 0, (LPARAM)&scroll_info);
-    todo_wine
     ok(res == 1, "SBM_GETSCROLLBARINFO returned %lu\n", res);
 
     DestroyWindow(hwnd);




More information about the wine-cvs mailing list