[PATCH 2/2] user32: Use correct values to select combo box text with EM_SETSEL
Hugh McMaster
hugh.mcmaster at outlook.com
Mon Jan 25 04:32:10 CST 2016
Signed-off-by: Hugh McMaster <hugh.mcmaster at outlook.com>
---
dlls/user32/combo.c | 11 +++++++----
dlls/user32/tests/combo.c | 4 ++--
2 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/dlls/user32/combo.c b/dlls/user32/combo.c
index 4c57b72..a0b0818 100644
--- a/dlls/user32/combo.c
+++ b/dlls/user32/combo.c
@@ -32,6 +32,7 @@
* - CB_SETTOPINDEX
*/
+#include <limits.h>
#include <stdarg.h>
#include <string.h>
@@ -686,7 +687,7 @@ static void CBPaintText(
static const WCHAR empty_stringW[] = { 0 };
if( CB_HASSTRINGS(lphc) ) SetWindowTextW( lphc->hWndEdit, pText ? pText : empty_stringW );
if( lphc->wState & CBF_FOCUSED )
- SendMessageW(lphc->hWndEdit, EM_SETSEL, 0, -1);
+ SendMessageW(lphc->hWndEdit, EM_SETSEL, 0, INT_MAX);
}
else /* paint text field ourselves */
{
@@ -959,7 +960,7 @@ static void CBUpdateEdit( LPHEADCOMBO lphc , INT index )
}
if( lphc->wState & CBF_FOCUSED )
- SendMessageW(lphc->hWndEdit, EM_SETSEL, 0, -1);
+ SendMessageW(lphc->hWndEdit, EM_SETSEL, 0, INT_MAX);
HeapFree( GetProcessHeap(), 0, pText );
}
@@ -1162,6 +1163,8 @@ static void COMBO_SetFocus( LPHEADCOMBO lphc )
{
if( CB_GETTYPE(lphc) == CBS_DROPDOWNLIST )
SendMessageW(lphc->hWndLBox, LB_CARETON, 0, 0);
+ else
+ SendMessageW(lphc->hWndEdit, EM_SETSEL, 0, INT_MAX);
/* This is wrong. Message sequences seem to indicate that this
is set *after* the notify. */
@@ -1300,7 +1303,7 @@ static LRESULT COMBO_Command( LPHEADCOMBO lphc, WPARAM wParam, HWND hWnd )
lphc->wState |= CBF_NOLBSELECT;
CBUpdateEdit( lphc, index );
/* select text in edit, as Windows does */
- SendMessageW(lphc->hWndEdit, EM_SETSEL, 0, -1);
+ SendMessageW(lphc->hWndEdit, EM_SETSEL, 0, INT_MAX);
}
else
{
@@ -1886,7 +1889,7 @@ LRESULT ComboWndProc_common( HWND hwnd, UINT message, WPARAM wParam, LPARAM lPar
SetFocus( lphc->hWndEdit );
/* The first time focus is received, select all the text */
if( !(lphc->wState & CBF_BEENFOCUSED) ) {
- SendMessageW(lphc->hWndEdit, EM_SETSEL, 0, -1);
+ SendMessageW(lphc->hWndEdit, EM_SETSEL, 0, INT_MAX);
lphc->wState |= CBF_BEENFOCUSED;
}
}
diff --git a/dlls/user32/tests/combo.c b/dlls/user32/tests/combo.c
index 2b3c4ee..cfaa3d2 100644
--- a/dlls/user32/tests/combo.c
+++ b/dlls/user32/tests/combo.c
@@ -613,7 +613,7 @@ static void test_editselection_focus(DWORD style)
SendMessageA(hCombo, WM_SETFOCUS, 0, (LPARAM)hEdit);
ok(setsel_start == 0, "Unexpected EM_SETSEL start value; got %ld\n", setsel_start);
- todo_wine ok(setsel_end == INT_MAX, "Unexpected EM_SETSEL end value; got %ld\n", setsel_end);
+ ok(setsel_end == INT_MAX, "Unexpected EM_SETSEL end value; got %ld\n", setsel_end);
ok(hCBN_SetFocus == hCombo, "Wrong handle set by CBN_SETFOCUS; got %p\n", hCBN_SetFocus);
ok(GetFocus() == hEdit, "hEdit should have keyboard focus\n");
@@ -626,7 +626,7 @@ static void test_editselection_focus(DWORD style)
SendMessageA(hCombo, WM_SETTEXT, 0, (LPARAM)wine_test);
SendMessageA(hMainWnd, WM_NEXTDLGCTL, (WPARAM)hCombo, TRUE);
ok(setsel_start == 0, "Unexpected EM_SETSEL start value; got %ld\n", setsel_start);
- todo_wine ok(setsel_end == INT_MAX, "Unexpected EM_SETSEL end value; got %ld\n", setsel_end);
+ ok(setsel_end == INT_MAX, "Unexpected EM_SETSEL end value; got %ld\n", setsel_end);
ok(hCBN_SetFocus == hCombo, "Wrong handle set by CBN_SETFOCUS; got %p\n", hCBN_SetFocus);
ok(GetFocus() == hEdit, "hEdit should have keyboard focus\n");
SendMessageA(hCombo, WM_GETTEXT, sizeof(buffer), (LPARAM)buffer);
--
1.9.1
More information about the wine-patches
mailing list