From 35135e5ddb64b1cdf63a18b2bee35385c023fabb Mon Sep 17 00:00:00 2001 From: James Tabor Date: Fri, 16 Jun 2006 15:33:59 +0000 Subject: [PATCH] Vitaly Lipatov : Fix character conversion in combo box. Which needed to be synced to wine. svn path=/trunk/; revision=22377 --- reactos/dll/win32/user32/controls/combo.c | 81 +++++++++++++++++------ 1 file changed, 60 insertions(+), 21 deletions(-) diff --git a/reactos/dll/win32/user32/controls/combo.c b/reactos/dll/win32/user32/controls/combo.c index cfa6b257860..d925f212517 100644 --- a/reactos/dll/win32/user32/controls/combo.c +++ b/reactos/dll/win32/user32/controls/combo.c @@ -432,6 +432,10 @@ static void CBCalcPlacement( lprLB->right = lprLB->left + lphc->droppedWidth; } + /* don't allow negative window width */ + if (lprEdit->right < lprEdit->left) + lprEdit->right = lprEdit->left; + TRACE("\ttext\t= (%ld,%ld-%ld,%ld)\n", lprEdit->left, lprEdit->top, lprEdit->right, lprEdit->bottom); @@ -1841,6 +1845,19 @@ static LRESULT COMBO_GetComboBoxInfo(LPHEADCOMBO lphc, COMBOBOXINFO *pcbi) return TRUE; } +static char *strdupA(LPCSTR str) +{ + char *ret; + DWORD len; + + if(!str) return NULL; + + len = strlen(str); + ret = HeapAlloc(GetProcessHeap(), 0, len + 1); + memcpy(ret, str, len + 1); + return ret; +} + /*********************************************************************** * ComboWndProc_common * @@ -2068,17 +2085,33 @@ static LRESULT ComboWndProc_common( HWND hwnd, UINT message, /* fall through */ #endif case CB_ADDSTRING: - { - UINT msg = LB_ADDSTRING; - if( lphc->dwStyle & CBS_LOWERCASE ) - msg = LB_ADDSTRING_LOWER; - else if( lphc->dwStyle & CBS_UPPERCASE ) - msg = LB_ADDSTRING_UPPER; - if( unicode ) - return SendMessageW(lphc->hWndLBox, msg, 0, lParam); - else - return SendMessageA(lphc->hWndLBox, msg, 0, lParam); - } + if( unicode ) + { + if( lphc->dwStyle & CBS_LOWERCASE ) + CharLowerW((LPWSTR)lParam); + else if( lphc->dwStyle & CBS_UPPERCASE ) + CharUpperW((LPWSTR)lParam); + return SendMessageW(lphc->hWndLBox, LB_ADDSTRING, 0, lParam); + } + else /* unlike the unicode version, the ansi version does not overwrite + the string if converting case */ + { + char *p, *string = NULL; + LRESULT ret; + if( lphc->dwStyle & CBS_LOWERCASE ) + { + string = strdupA((LPSTR)lParam); + CharLowerA(string); + } + else if( lphc->dwStyle & CBS_UPPERCASE ) + { + string = strdupA((LPSTR)lParam); + CharUpperA(string); + } + ret = SendMessageA(lphc->hWndLBox, LB_ADDSTRING, 0, string ? (LPARAM)string : lParam); + HeapFree(GetProcessHeap(), 0, string); + return ret; + } #ifndef __REACTOS__ case CB_INSERTSTRING16: wParam = (INT)(INT16)wParam; @@ -2086,17 +2119,23 @@ static LRESULT ComboWndProc_common( HWND hwnd, UINT message, /* fall through */ #endif case CB_INSERTSTRING: - { - UINT msg = LB_INSERTSTRING; - if( lphc->dwStyle & CBS_LOWERCASE ) - msg = LB_INSERTSTRING_LOWER; - else if( lphc->dwStyle & CBS_UPPERCASE ) - msg = LB_INSERTSTRING_UPPER; - if( unicode ) - return SendMessageW(lphc->hWndLBox, msg, 0, lParam); + if( unicode ) + { + if( lphc->dwStyle & CBS_LOWERCASE ) + CharLowerW((LPWSTR)lParam); + else if( lphc->dwStyle & CBS_UPPERCASE ) + CharUpperW((LPWSTR)lParam); + return SendMessageW(lphc->hWndLBox, LB_INSERTSTRING, wParam, lParam); + } else - return SendMessageA(lphc->hWndLBox, msg, 0, lParam); - } + { + char *p; + if( lphc->dwStyle & CBS_LOWERCASE ) + CharLowerA((LPSTR)lParam); + else if( lphc->dwStyle & CBS_UPPERCASE ) + CharUpperA((LPSTR)lParam); + return SendMessageA(lphc->hWndLBox, LB_INSERTSTRING, wParam, lParam); + } #ifndef __REACTOS__ case CB_DELETESTRING16: #endif