Make sure edit and listbox controls are of same ASCII/Unicode style as
the combo box. Fixed a few MBCS issues with WM_GETTEXTLENGTH handling.
diff --git a/controls/combo.c b/controls/combo.c
index cb1ac9b..49215e7 100644
--- a/controls/combo.c
+++ b/controls/combo.c
@@ -492,7 +492,8 @@
/***********************************************************************
* COMBO_Create
*/
-static LRESULT COMBO_Create( HWND hwnd, LPHEADCOMBO lphc, HWND hwndParent, LONG style )
+static LRESULT COMBO_Create( HWND hwnd, LPHEADCOMBO lphc, HWND hwndParent, LONG style,
+ BOOL unicode )
{
static const WCHAR clbName[] = {'C','o','m','b','o','L','B','o','x',0};
static const WCHAR editName[] = {'E','d','i','t',0};
@@ -574,16 +575,22 @@
}
}
- lphc->hWndLBox = CreateWindowExW(lbeExStyle,
- clbName,
- NULL,
- lbeStyle,
- lphc->droppedRect.left,
- lphc->droppedRect.top,
- lphc->droppedRect.right - lphc->droppedRect.left,
- lphc->droppedRect.bottom - lphc->droppedRect.top,
- hwnd, (HMENU)ID_CB_LISTBOX,
- GetWindowLongA( hwnd, GWL_HINSTANCE ), lphc );
+ if (unicode)
+ lphc->hWndLBox = CreateWindowExW(lbeExStyle, clbName, NULL, lbeStyle,
+ lphc->droppedRect.left,
+ lphc->droppedRect.top,
+ lphc->droppedRect.right - lphc->droppedRect.left,
+ lphc->droppedRect.bottom - lphc->droppedRect.top,
+ hwnd, (HMENU)ID_CB_LISTBOX,
+ GetWindowLongA( hwnd, GWL_HINSTANCE ), lphc );
+ else
+ lphc->hWndLBox = CreateWindowExA(lbeExStyle, "ComboLBox", NULL, lbeStyle,
+ lphc->droppedRect.left,
+ lphc->droppedRect.top,
+ lphc->droppedRect.right - lphc->droppedRect.left,
+ lphc->droppedRect.bottom - lphc->droppedRect.top,
+ hwnd, (HMENU)ID_CB_LISTBOX,
+ GetWindowLongA( hwnd, GWL_HINSTANCE ), lphc );
if( lphc->hWndLBox )
{
@@ -610,15 +617,20 @@
if (!IsWindowEnabled(hwnd)) lbeStyle |= WS_DISABLED;
- lphc->hWndEdit = CreateWindowExW(0,
- editName,
- NULL,
- lbeStyle,
- lphc->textRect.left, lphc->textRect.top,
- lphc->textRect.right - lphc->textRect.left,
- lphc->textRect.bottom - lphc->textRect.top,
- hwnd, (HMENU)ID_CB_EDIT,
- GetWindowLongA( hwnd, GWL_HINSTANCE ), NULL );
+ if (unicode)
+ lphc->hWndEdit = CreateWindowExW(0, editName, NULL, lbeStyle,
+ lphc->textRect.left, lphc->textRect.top,
+ lphc->textRect.right - lphc->textRect.left,
+ lphc->textRect.bottom - lphc->textRect.top,
+ hwnd, (HMENU)ID_CB_EDIT,
+ GetWindowLongA( hwnd, GWL_HINSTANCE ), NULL );
+ else
+ lphc->hWndEdit = CreateWindowExA(0, "Edit", NULL, lbeStyle,
+ lphc->textRect.left, lphc->textRect.top,
+ lphc->textRect.right - lphc->textRect.left,
+ lphc->textRect.bottom - lphc->textRect.top,
+ hwnd, (HMENU)ID_CB_EDIT,
+ GetWindowLongA( hwnd, GWL_HINSTANCE ), NULL );
if( !lphc->hWndEdit )
bEdit = FALSE;
@@ -1907,7 +1919,7 @@
hwndParent = ((LPCREATESTRUCTA)lParam)->hwndParent;
style = ((LPCREATESTRUCTA)lParam)->style;
}
- return COMBO_Create(hwnd, lphc, hwndParent, style);
+ return COMBO_Create(hwnd, lphc, hwndParent, style, unicode);
}
case WM_PRINTCLIENT:
@@ -1973,9 +1985,10 @@
case WM_CLEAR:
if ((message == WM_GETTEXTLENGTH) && !ISWIN31 && !(lphc->wState & CBF_EDIT))
{
- int j = SendMessageW(lphc->hWndLBox, LB_GETCURSEL, 0, 0);
- if (j == -1) return 0;
- return SendMessageW(lphc->hWndLBox, LB_GETTEXTLEN, j, 0);
+ int j = SendMessageW(lphc->hWndLBox, LB_GETCURSEL, 0, 0);
+ if (j == -1) return 0;
+ return unicode ? SendMessageW(lphc->hWndLBox, LB_GETTEXTLEN, j, 0) :
+ SendMessageA(lphc->hWndLBox, LB_GETTEXTLEN, j, 0);
}
else if( lphc->wState & CBF_EDIT )
{
@@ -2218,7 +2231,8 @@
wParam = (INT)(INT16)wParam;
/* fall through */
case CB_GETLBTEXTLEN:
- return SendMessageW(lphc->hWndLBox, LB_GETTEXTLEN, wParam, 0);
+ return unicode ? SendMessageW(lphc->hWndLBox, LB_GETTEXTLEN, wParam, 0) :
+ SendMessageA(lphc->hWndLBox, LB_GETTEXTLEN, wParam, 0);
case CB_GETITEMDATA16:
wParam = (INT)(INT16)wParam;
/* fall through */
diff --git a/controls/edit.c b/controls/edit.c
index 2209a15..68f66ab 100644
--- a/controls/edit.c
+++ b/controls/edit.c
@@ -969,7 +969,9 @@
case WM_GETTEXTLENGTH:
DPRINTF_EDIT_MSG32("WM_GETTEXTLENGTH");
- result = strlenW(es->text);
+ if (unicode) result = strlenW(es->text);
+ else result = WideCharToMultiByte( CP_ACP, 0, es->text, strlenW(es->text),
+ NULL, 0, NULL, NULL );
break;
case WM_HSCROLL:
diff --git a/controls/listbox.c b/controls/listbox.c
index 951f548..e537a5e 100644
--- a/controls/listbox.c
+++ b/controls/listbox.c
@@ -2608,8 +2608,10 @@
case LB_GETTEXTLEN:
if ((INT)wParam >= descr->nb_items || (INT)wParam < 0)
return LB_ERR;
- return (HAS_STRINGS(descr) ? strlenW(descr->items[wParam].str)
- : sizeof(DWORD));
+ if (!HAS_STRINGS(descr)) return sizeof(DWORD);
+ if (unicode) return strlenW( descr->items[wParam].str );
+ return WideCharToMultiByte( CP_ACP, 0, descr->items[wParam].str,
+ strlenW(descr->items[wParam].str), NULL, 0, NULL, NULL );
case LB_GETCURSEL16:
case LB_GETCURSEL: