[PATCH 4/7] win32u: Move scroll bar WM_CREATE implementation from user32.

Jacek Caban wine at gitlab.winehq.org
Mon Jul 4 07:05:55 CDT 2022


From: Jacek Caban <jacek at codeweavers.com>

---
 dlls/user32/scroll.c         | 81 +-----------------------------------
 dlls/win32u/ntuser_private.h |  6 +++
 dlls/win32u/scroll.c         | 62 +++++++++++++++++++++++++++
 3 files changed, 70 insertions(+), 79 deletions(-)

diff --git a/dlls/user32/scroll.c b/dlls/user32/scroll.c
index 9cb07af0706..cc847b48ec6 100644
--- a/dlls/user32/scroll.c
+++ b/dlls/user32/scroll.c
@@ -32,6 +32,7 @@
 WINE_DEFAULT_DEBUG_CHANNEL(scroll);
 
 typedef struct scroll_info SCROLLBAR_INFO, *LPSCROLLBAR_INFO;
+typedef struct scroll_bar_win_data SCROLLBAR_WNDDATA;
 
 /* data for window that has (one or two) scroll bars */
 typedef struct
@@ -40,12 +41,6 @@ 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 */
@@ -1127,75 +1122,6 @@ void SCROLL_TrackScrollBar( HWND hwnd, INT scrollbar, POINT pt )
 }
 
 
-/***********************************************************************
- *           SCROLL_CreateScrollBar
- *
- * Create a scroll bar
- *
- * PARAMS
- *    hwnd     [I] Handle of window with scrollbar(s)
- *    lpCreate [I] The style and place of the scroll bar
- */
-static void SCROLL_CreateScrollBar(HWND hwnd, LPCREATESTRUCTW lpCreate)
-{
-    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)
-            NtUserMoveWindow( hwnd, lpCreate->x, lpCreate->y, GetSystemMetrics(SM_CXVSCROLL)+1,
-                              GetSystemMetrics(SM_CYHSCROLL)+1, FALSE );
-        else if(lpCreate->style & SBS_SIZEBOXBOTTOMRIGHTALIGN)
-            NtUserMoveWindow( hwnd, lpCreate->x+lpCreate->cx-GetSystemMetrics(SM_CXVSCROLL)-1,
-                              lpCreate->y+lpCreate->cy-GetSystemMetrics(SM_CYHSCROLL)-1,
-                              GetSystemMetrics(SM_CXVSCROLL)+1,
-                              GetSystemMetrics(SM_CYHSCROLL)+1, FALSE );
-    }
-    else if (lpCreate->style & SBS_VERT)
-    {
-        if (lpCreate->style & SBS_LEFTALIGN)
-            NtUserMoveWindow( hwnd, lpCreate->x, lpCreate->y,
-                              GetSystemMetrics(SM_CXVSCROLL)+1, lpCreate->cy, FALSE );
-        else if (lpCreate->style & SBS_RIGHTALIGN)
-            NtUserMoveWindow( hwnd,
-                              lpCreate->x+lpCreate->cx-GetSystemMetrics(SM_CXVSCROLL)-1,
-                              lpCreate->y,
-                              GetSystemMetrics(SM_CXVSCROLL)+1, lpCreate->cy, FALSE );
-    }
-    else  /* SBS_HORZ */
-    {
-        if (lpCreate->style & SBS_TOPALIGN)
-            NtUserMoveWindow( hwnd, lpCreate->x, lpCreate->y,
-                              lpCreate->cx, GetSystemMetrics(SM_CYHSCROLL)+1, FALSE );
-        else if (lpCreate->style & SBS_BOTTOMALIGN)
-            NtUserMoveWindow( hwnd,
-                              lpCreate->x,
-                              lpCreate->y+lpCreate->cy-GetSystemMetrics(SM_CYHSCROLL)-1,
-                              lpCreate->cx, GetSystemMetrics(SM_CYHSCROLL)+1, FALSE );
-    }
-}
-
-
 /*************************************************************************
  *           SCROLL_GetScrollInfo
  *
@@ -1409,10 +1335,6 @@ LRESULT WINAPI USER_ScrollBarProc( HWND hwnd, UINT message, WPARAM wParam, LPARA
 
     switch(message)
     {
-    case WM_CREATE:
-        SCROLL_CreateScrollBar(hwnd, (LPCREATESTRUCTW)lParam);
-        break;
-
     case WM_ENABLE:
         {
 	    SCROLLBAR_INFO *infoPtr;
@@ -1503,6 +1425,7 @@ LRESULT WINAPI USER_ScrollBarProc( HWND hwnd, UINT message, WPARAM wParam, LPARA
         }
         break;
 
+    case WM_CREATE:
     case WM_ERASEBKGND:
     case WM_GETDLGCODE:
         return NtUserMessageCall( hwnd, message, wParam, lParam, 0, NtUserScrollBarWndProc, !unicode );
diff --git a/dlls/win32u/ntuser_private.h b/dlls/win32u/ntuser_private.h
index 609f7018b07..36c11a49c4e 100644
--- a/dlls/win32u/ntuser_private.h
+++ b/dlls/win32u/ntuser_private.h
@@ -216,6 +216,12 @@ struct scroll_info
     BOOL  painted;  /* Whether the scroll bar is painted by DefWinProc() */
 };
 
+struct scroll_bar_win_data
+{
+    DWORD magic;
+    struct scroll_info info;
+};
+
 /* FIXME: make it private to class.c */
 typedef struct tagWINDOWPROC
 {
diff --git a/dlls/win32u/scroll.c b/dlls/win32u/scroll.c
index d6c21fc6992..a15c8bfd36d 100644
--- a/dlls/win32u/scroll.c
+++ b/dlls/win32u/scroll.c
@@ -30,6 +30,8 @@
 WINE_DEFAULT_DEBUG_CHANNEL(scroll);
 
 
+#define SCROLLBAR_MAGIC 0x5c6011ba
+
 static struct scroll_info *get_scroll_info_ptr( HWND hwnd, int bar, BOOL alloc )
 {
     struct scroll_info *ret = NULL;
@@ -82,10 +84,70 @@ static BOOL show_scroll_bar( HWND hwnd, int bar, BOOL show_horz, BOOL show_vert
     return FALSE; /* no frame changes */
 }
 
+static void create_scroll_bar( HWND hwnd, CREATESTRUCTW *create )
+{
+    struct scroll_info *info = NULL;
+    WND *win;
+
+    TRACE( "hwnd=%p create=%p\n", hwnd, create );
+
+    win = get_win_ptr( hwnd );
+    if (win->cbWndExtra >= sizeof(struct scroll_bar_win_data))
+    {
+        struct scroll_bar_win_data *data = (struct scroll_bar_win_data *)win->wExtra;
+        data->magic = SCROLLBAR_MAGIC;
+        info = &data->info;
+    }
+    else WARN( "Not enough extra data\n" );
+    release_win_ptr( win );
+    if (!info) return;
+
+    if (create->style & WS_DISABLED)
+    {
+        info->flags = ESB_DISABLE_BOTH;
+        TRACE( "Created WS_DISABLED scrollbar\n" );
+    }
+
+    if (create->style & (SBS_SIZEGRIP | SBS_SIZEBOX))
+    {
+        if (create->style & SBS_SIZEBOXTOPLEFTALIGN)
+            NtUserMoveWindow( hwnd, create->x, create->y, get_system_metrics( SM_CXVSCROLL ) + 1,
+                              get_system_metrics( SM_CYHSCROLL ) + 1, FALSE );
+        else if(create->style & SBS_SIZEBOXBOTTOMRIGHTALIGN)
+            NtUserMoveWindow( hwnd, create->x + create->cx - get_system_metrics( SM_CXVSCROLL ) - 1,
+                              create->y + create->cy-get_system_metrics( SM_CYHSCROLL ) - 1,
+                              get_system_metrics( SM_CXVSCROLL ) + 1,
+                              get_system_metrics( SM_CYHSCROLL ) + 1, FALSE );
+    }
+    else if (create->style & SBS_VERT)
+    {
+        if (create->style & SBS_LEFTALIGN)
+            NtUserMoveWindow( hwnd, create->x, create->y, get_system_metrics( SM_CXVSCROLL ) + 1,
+                              create->cy, FALSE );
+        else if (create->style & SBS_RIGHTALIGN)
+            NtUserMoveWindow( hwnd, create->x + create->cx - get_system_metrics( SM_CXVSCROLL ) - 1,
+                              create->y, get_system_metrics( SM_CXVSCROLL ) + 1, create->cy, FALSE );
+    }
+    else  /* SBS_HORZ */
+    {
+        if (create->style & SBS_TOPALIGN)
+            NtUserMoveWindow( hwnd, create->x, create->y, create->cx,
+                              get_system_metrics( SM_CYHSCROLL ) + 1, FALSE );
+        else if (create->style & SBS_BOTTOMALIGN)
+            NtUserMoveWindow( hwnd, create->x,
+                              create->y + create->cy - get_system_metrics( SM_CYHSCROLL ) - 1,
+                              create->cx, get_system_metrics( SM_CYHSCROLL ) + 1, FALSE );
+    }
+}
+
 LRESULT scroll_bar_window_proc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam, BOOL ansi )
 {
     switch (msg)
     {
+    case WM_CREATE:
+        create_scroll_bar( hwnd, (CREATESTRUCTW *)lparam );
+        return 0;
+
     case WM_ERASEBKGND:
         return 1;
 
-- 
GitLab


https://gitlab.winehq.org/wine/wine/-/merge_requests/368



More information about the wine-devel mailing list