Huw Davies : comctl32: Wrap the buttons inside the toolbar's client rect.

Alexandre Julliard julliard at wine.codeweavers.com
Tue May 19 09:53:21 CDT 2015


Module: wine
Branch: master
Commit: 797f42699e86a0e4e3468b55f88e7b8e6d06f323
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=797f42699e86a0e4e3468b55f88e7b8e6d06f323

Author: Huw Davies <huw at codeweavers.com>
Date:   Tue May 19 12:51:56 2015 +0100

comctl32: Wrap the buttons inside the toolbar's client rect.

The toolbar need not be the same width as the parent.

---

 dlls/comctl32/tests/toolbar.c | 56 +++++++++++++++++++++++++++++++++++++++++++
 dlls/comctl32/toolbar.c       | 17 +------------
 2 files changed, 57 insertions(+), 16 deletions(-)

diff --git a/dlls/comctl32/tests/toolbar.c b/dlls/comctl32/tests/toolbar.c
index 4bbffd3..2041216 100644
--- a/dlls/comctl32/tests/toolbar.c
+++ b/dlls/comctl32/tests/toolbar.c
@@ -2024,6 +2024,61 @@ static void test_TB_GET_SET_EXTENDEDSTYLE(void)
     DestroyWindow(hwnd);
 }
 
+static void test_noresize(void)
+{
+    HWND wnd;
+    int i;
+    TBBUTTON button = {0, 10, TBSTATE_ENABLED, 0, {0, }, 0, -1};
+
+    wnd = CreateWindowExA(0, TOOLBARCLASSNAMEA, NULL, WS_CHILD | WS_VISIBLE | CCS_NORESIZE | TBSTYLE_WRAPABLE, 0, 0, 100, 20,
+                          hMainWnd, (HMENU)5, GetModuleHandleA(NULL), NULL);
+    SendMessageA(wnd, TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0);
+
+    for (i=0; i<30; i++)
+    {
+        button.idCommand = 10 + i;
+        SendMessageA(wnd, TB_ADDBUTTONSA, 1, (LPARAM)&button);
+    }
+
+    SendMessageA(wnd, TB_SETSTATE, 10, TBSTATE_WRAP|TBSTATE_ENABLED);
+
+    /* autosize clears the wrap on button 0 */
+    SendMessageA(wnd, TB_AUTOSIZE, 0, 0);
+    for (i=0; i<30; i++)
+    {
+        SendMessageA(wnd, TB_GETBUTTON, i, (LPARAM)&button);
+        if (i % 4 == 3)
+            ok(button.fsState == (TBSTATE_WRAP|TBSTATE_ENABLED), "%d: got %08x\n", i, button.fsState);
+        else
+            ok(button.fsState == TBSTATE_ENABLED, "%d: got %08x\n", i, button.fsState);
+    }
+
+    /* changing the parent doesn't do anything */
+    MoveWindow(hMainWnd, 0,0, 400, 200, FALSE);
+    for (i=0; i<30; i++)
+    {
+        SendMessageA(wnd, TB_GETBUTTON, i, (LPARAM)&button);
+        if (i % 4 == 3)
+            ok(button.fsState == (TBSTATE_WRAP|TBSTATE_ENABLED), "%d: got %08x\n", i, button.fsState);
+        else
+            ok(button.fsState == TBSTATE_ENABLED, "%d: got %08x\n", i, button.fsState);
+    }
+
+    /* again nothing here */
+    SendMessageA(wnd, TB_AUTOSIZE, 0, 0);
+    for (i=0; i<30; i++)
+    {
+        SendMessageA(wnd, TB_GETBUTTON, i, (LPARAM)&button);
+        if (i % 4 == 3)
+            ok(button.fsState == (TBSTATE_WRAP|TBSTATE_ENABLED), "%d: got %08x\n", i, button.fsState);
+        else
+            ok(button.fsState == TBSTATE_ENABLED, "%d: got %08x\n", i, button.fsState);
+    }
+
+    DestroyWindow(wnd);
+
+}
+
 START_TEST(toolbar)
 {
     WNDCLASSA wc;
@@ -2066,6 +2121,7 @@ START_TEST(toolbar)
     test_get_set_style();
     test_create();
     test_TB_GET_SET_EXTENDEDSTYLE();
+    test_noresize();
 
     PostQuitMessage(0);
     while(GetMessageA(&msg,0,0,0)) {
diff --git a/dlls/comctl32/toolbar.c b/dlls/comctl32/toolbar.c
index 97d509e..9f70063 100644
--- a/dlls/comctl32/toolbar.c
+++ b/dlls/comctl32/toolbar.c
@@ -1282,7 +1282,6 @@ TOOLBAR_WrapToolbar(TOOLBAR_INFO *infoPtr)
 {
     TBUTTON_INFO *btnPtr;
     INT x, cx, i, j, width;
-    RECT rc;
     BOOL bButtonWrap;
 
     /* 	When the toolbar window style is not TBSTYLE_WRAPABLE,	*/
@@ -1293,21 +1292,7 @@ TOOLBAR_WrapToolbar(TOOLBAR_INFO *infoPtr)
 
     btnPtr = infoPtr->buttons;
     x  = infoPtr->nIndent;
-
-    if (GetParent(infoPtr->hwndSelf))
-    {
-        /* this can get the parents width, to know how far we can extend
-         * this toolbar.  We cannot use its height, as there may be multiple
-         * toolbars in a rebar control
-         */
-        GetClientRect( GetParent(infoPtr->hwndSelf), &rc );
-        width = rc.right - rc.left;
-    }
-    else
-    {
-        GetWindowRect( infoPtr->hwndSelf, &rc );
-        width = rc.right - rc.left;
-    }
+    width = infoPtr->client_rect.right - infoPtr->client_rect.left;
 
     bButtonWrap = FALSE;
 




More information about the wine-cvs mailing list