(resubmit) user32: In COMBO_WindowPosChanging() do not change the height of the the dropped rectangle, if the new height is too small

Rein Klazes wijn at online.nl
Thu Apr 2 04:37:10 CDT 2009


Fixes bug #17695
---
 dlls/user32/combo.c       |    6 ++--
 dlls/user32/tests/combo.c |   46 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 49 insertions(+), 3 deletions(-)

diff --git a/dlls/user32/combo.c b/dlls/user32/combo.c
index 6e74154..7fd5d9e 100644
--- a/dlls/user32/combo.c
+++ b/dlls/user32/combo.c
@@ -482,20 +482,20 @@ static LRESULT COMBO_WindowPosChanging(
     /*
      * Resizing a combobox has another side effect, it resizes the dropped
      * rectangle as well. However, it does it only if the new height for the
-     * combobox is different from the height it should have. In other words,
+     * combobox is more than the height it should have. In other words,
      * if the application resizing the combobox only had the intention to resize
      * the actual control, for example, to do the layout of a dialog that is
      * resized, the height of the dropdown is not changed.
      */
-    if (posChanging->cy != newComboHeight)
+    if (posChanging->cy > newComboHeight)
     {
 	TRACE("posChanging->cy=%d, newComboHeight=%d, oldbot=%d, oldtop=%d\n",
 	      posChanging->cy, newComboHeight, lphc->droppedRect.bottom,
 	      lphc->droppedRect.top);
       lphc->droppedRect.bottom = lphc->droppedRect.top + posChanging->cy - newComboHeight;
 
-      posChanging->cy = newComboHeight;
     }
+    posChanging->cy = newComboHeight;
   }
 
   return 0;
diff --git a/dlls/user32/tests/combo.c b/dlls/user32/tests/combo.c
index cc55864..b722f50 100644
--- a/dlls/user32/tests/combo.c
+++ b/dlls/user32/tests/combo.c
@@ -355,6 +355,50 @@ static void test_WM_LBUTTONDOWN(void)
     DestroyWindow(hCombo);
 }
 
+static void test_changesize( DWORD style)
+{
+    HWND hCombo = build_combo(style);
+    RECT rc;
+    INT ddheight, clheight, ddwidth, clwidth;
+    /* get initial measurements */
+    GetClientRect( hCombo, &rc);
+    clheight = rc.bottom - rc.top;
+    clwidth = rc.right - rc.left;
+    SendMessageA(hCombo, CB_GETDROPPEDCONTROLRECT, 0, (LPARAM)&rc);
+    ddheight = rc.bottom - rc.top;
+    ddwidth = rc.right - rc.left;
+    /* use MoveWindow to move & resize the combo */
+    /* first make it slightly smaller */
+    MoveWindow( hCombo, 10, 10, clwidth - 2, clheight - 2, TRUE);
+    GetClientRect( hCombo, &rc);
+    ok( rc.right - rc.left == clwidth - 2, "clientrect witdh is %d vs %d\n",
+            rc.right - rc.left, clwidth - 2);
+    todo_wine {
+        ok( rc.bottom - rc.top == clheight, "clientrect height is %d vs %d\n",
+                rc.bottom - rc.top, clheight);
+    }
+    SendMessageA(hCombo, CB_GETDROPPEDCONTROLRECT, 0, (LPARAM)&rc);
+    ok( rc.right - rc.left == clwidth - 2, "drop-down rect witdh is %d vs %d\n",
+            rc.right - rc.left, clwidth - 2);
+    ok( rc.bottom - rc.top == ddheight, "drop-down rect height is %d vs %d\n",
+            rc.bottom - rc.top, ddheight);
+    /* new cx, cy is slightly bigger then the initial values */
+    MoveWindow( hCombo, 10, 10, clwidth + 2, clheight + 2, TRUE);
+    GetClientRect( hCombo, &rc);
+    ok( rc.right - rc.left == clwidth + 2, "clientrect witdh is %d vs %d\n",
+            rc.right - rc.left, clwidth + 2);
+    ok( rc.bottom - rc.top == clheight, "clientrect height is %d vs %d\n",
+            rc.bottom - rc.top, clheight);
+    SendMessageA(hCombo, CB_GETDROPPEDCONTROLRECT, 0, (LPARAM)&rc);
+    ok( rc.right - rc.left == clwidth + 2, "drop-down rect witdh is %d vs %d\n",
+            rc.right - rc.left, clwidth + 2);
+    todo_wine {
+        ok( rc.bottom - rc.top == clheight + 2, "drop-down rect height is %d vs %d\n",
+                rc.bottom - rc.top, clheight + 2);
+    }
+    DestroyWindow(hCombo);
+}
+
 START_TEST(combo)
 {
     hMainWnd = CreateWindow("static", "Test", WS_OVERLAPPEDWINDOW, 10, 10, 300, 300, NULL, NULL, NULL, 0);
@@ -366,6 +410,8 @@ START_TEST(combo)
     test_setitemheight(CBS_DROPDOWNLIST);
     test_CBN_SELCHANGE();
     test_WM_LBUTTONDOWN();
+    test_changesize(CBS_DROPDOWN);
+    test_changesize(CBS_DROPDOWNLIST);
 
     DestroyWindow(hMainWnd);
 }
-- 
1.6.2.1




More information about the wine-patches mailing list