From 8ac8957a36b559014f71e78d79394f613b9d2aed Mon Sep 17 00:00:00 2001 From: Rein Klazes Date: Fri, 3 Apr 2009 07:49:34 +0200 Subject: [PATCH] user32: In COMBO_WindowPosChanging() do not change the height of the the dropped rectangle, if the new height is too small. --- dlls/user32/combo.c | 6 +++--- dlls/user32/tests/combo.c | 44 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 3 deletions(-) diff --git a/dlls/user32/combo.c b/dlls/user32/combo.c index 6e741544730..7fd5d9e8f40 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 cc5586429d9..bf2f5c723e0 100644 --- a/dlls/user32/tests/combo.c +++ b/dlls/user32/tests/combo.c @@ -355,6 +355,48 @@ 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); + 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 +408,8 @@ START_TEST(combo) test_setitemheight(CBS_DROPDOWNLIST); test_CBN_SELCHANGE(); test_WM_LBUTTONDOWN(); + test_changesize(CBS_DROPDOWN); + test_changesize(CBS_DROPDOWNLIST); DestroyWindow(hMainWnd); }