From 7c76a79ffa199c892f9d555bc12e2dd4fe58b1b1 Mon Sep 17 00:00:00 2001 From: Bruno Jesus <00cpxxx@gmail.com> Date: Thu, 1 Sep 2011 02:30:50 -0300 Subject: [PATCH] user32: Fix support for CB_SETDROPPEDWIDTH in combobox. --- dlls/user32/combo.c | 18 ++++++++++++++---- dlls/user32/tests/combo.c | 22 ++++++++++++++++------ 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/dlls/user32/combo.c b/dlls/user32/combo.c index 9c22df6b385..4a839ec8cd5 100644 --- a/dlls/user32/combo.c +++ b/dlls/user32/combo.c @@ -2112,14 +2112,24 @@ LRESULT ComboWndProc_common( HWND hwnd, UINT message, WPARAM wParam, LPARAM lPar return SendMessageW(lphc->hWndLBox, LB_GETLOCALE, 0, 0); case CB_SETLOCALE: return SendMessageW(lphc->hWndLBox, LB_SETLOCALE, wParam, 0); + case CB_SETDROPPEDWIDTH: + if( (CB_GETTYPE(lphc) == CBS_SIMPLE) || + (INT)wParam >= 32768 ) + return CB_ERR; + /* new value must be higher than combobox width */ + if((INT)wParam >= lphc->droppedRect.right - lphc->droppedRect.left) + lphc->droppedWidth = wParam; + else if(wParam) + lphc->droppedWidth = 0; + + /* recalculate the combobox area */ + CBCalcPlacement(hwnd, lphc, &lphc->textRect, &lphc->buttonRect, &lphc->droppedRect ); + + /* fall through */ case CB_GETDROPPEDWIDTH: if( lphc->droppedWidth ) return lphc->droppedWidth; return lphc->droppedRect.right - lphc->droppedRect.left; - case CB_SETDROPPEDWIDTH: - if( (CB_GETTYPE(lphc) != CBS_SIMPLE) && - (INT)wParam < 32768 ) lphc->droppedWidth = (INT)wParam; - return CB_ERR; case CB_GETDROPPEDCONTROLRECT: if( lParam ) CBGetDroppedControlRect(lphc, (LPRECT)lParam ); return CB_OKAY; diff --git a/dlls/user32/tests/combo.c b/dlls/user32/tests/combo.c index eabeeb0e717..af23f96d1c1 100644 --- a/dlls/user32/tests/combo.c +++ b/dlls/user32/tests/combo.c @@ -406,25 +406,35 @@ static void test_changesize( DWORD style) } ddwidth = SendMessageA(hCombo, CB_SETDROPPEDWIDTH, -1, 0); - todo_wine ok( ddwidth == clwidth + 2, "drop-width is %d vs %d\n", ddwidth, clwidth + 2); + ok( ddwidth == clwidth + 2, "drop-width is %d vs %d\n", ddwidth, clwidth + 2); ddwidth = SendMessageA(hCombo, CB_GETDROPPEDWIDTH, 0, 0); - todo_wine ok( ddwidth == clwidth + 2, "drop-width is %d vs %d\n", ddwidth, clwidth + 2); + ok( ddwidth == clwidth + 2, "drop-width is %d vs %d\n", ddwidth, clwidth + 2); ddwidth = SendMessageA(hCombo, CB_SETDROPPEDWIDTH, 0, 0); - todo_wine ok( ddwidth == clwidth + 2, "drop-width is %d vs %d\n", ddwidth, clwidth + 2); + ok( ddwidth == clwidth + 2, "drop-width is %d vs %d\n", ddwidth, clwidth + 2); ddwidth = SendMessageA(hCombo, CB_GETDROPPEDWIDTH, 0, 0); ok( ddwidth == clwidth + 2, "drop-width is %d vs %d\n", ddwidth, clwidth + 2); ddwidth = SendMessageA(hCombo, CB_SETDROPPEDWIDTH, clwidth - 1, 0); - todo_wine ok( ddwidth == clwidth + 2, "drop-width is %d vs %d\n", ddwidth, clwidth + 2); + ok( ddwidth == clwidth + 2, "drop-width is %d vs %d\n", ddwidth, clwidth + 2); ddwidth = SendMessageA(hCombo, CB_GETDROPPEDWIDTH, 0, 0); - todo_wine ok( ddwidth == clwidth + 2, "drop-width is %d vs %d\n", ddwidth, clwidth + 2); + ok( ddwidth == clwidth + 2, "drop-width is %d vs %d\n", ddwidth, clwidth + 2); ddwidth = SendMessageA(hCombo, CB_SETDROPPEDWIDTH, clwidth << 1, 0); - todo_wine ok( ddwidth == (clwidth << 1), "drop-width is %d vs %d\n", ddwidth, clwidth << 1); + ok( ddwidth == (clwidth << 1), "drop-width is %d vs %d\n", ddwidth, clwidth << 1); ddwidth = SendMessageA(hCombo, CB_GETDROPPEDWIDTH, 0, 0); ok( ddwidth == (clwidth << 1), "drop-width is %d vs %d\n", ddwidth, clwidth << 1); + ddwidth = SendMessageA(hCombo, CB_SETDROPPEDWIDTH, 0, 0); + ok( ddwidth == (clwidth << 1), "drop-width is %d vs %d\n", ddwidth, clwidth << 1); + ddwidth = SendMessageA(hCombo, CB_GETDROPPEDWIDTH, 0, 0); + ok( ddwidth == (clwidth << 1), "drop-width is %d vs %d\n", ddwidth, clwidth << 1); + + ddwidth = SendMessageA(hCombo, CB_SETDROPPEDWIDTH, 1, 0); + ok( ddwidth == clwidth + 2, "drop-width is %d vs %d\n", ddwidth, clwidth + 2); + ddwidth = SendMessageA(hCombo, CB_GETDROPPEDWIDTH, 0, 0); + ok( ddwidth == clwidth + 2, "drop-width is %d vs %d\n", ddwidth, clwidth + 2); + DestroyWindow(hCombo); }