diff --git a/dlls/user32/combo.c b/dlls/user32/combo.c index 85e372adedc..d31f17ec885 100644 --- a/dlls/user32/combo.c +++ b/dlls/user32/combo.c @@ -1910,8 +1910,14 @@ LRESULT ComboWndProc_common( HWND hwnd, UINT message, WPARAM wParam, LPARAM lPar case WM_GETFONT: return (LRESULT)lphc->hFont; case WM_SETFOCUS: - if( lphc->wState & CBF_EDIT ) - SetFocus( lphc->hWndEdit ); + if( lphc->wState & CBF_EDIT ) { + 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); + lphc->wState |= CBF_BEENFOCUSED; + } + } else COMBO_SetFocus( lphc ); return TRUE; diff --git a/dlls/user32/controls.h b/dlls/user32/controls.h index 8275ee53242..205492243fa 100644 --- a/dlls/user32/controls.h +++ b/dlls/user32/controls.h @@ -199,6 +199,7 @@ extern INT SCROLL_SetNCSbState( HWND hwnd, int vMin, int vMax, int vPos, #define CBF_SELCHANGE 0x0400 #define CBF_NOEDITNOTIFY 0x1000 #define CBF_NOLBSELECT 0x2000 /* do not change current selection */ +#define CBF_BEENFOCUSED 0x4000 /* has it ever had focus */ #define CBF_EUI 0x8000 /* combo state struct */ diff --git a/dlls/user32/tests/combo.c b/dlls/user32/tests/combo.c index b0f7488238f..bee685cb3ea 100644 --- a/dlls/user32/tests/combo.c +++ b/dlls/user32/tests/combo.c @@ -449,13 +449,13 @@ static void test_editselection(void) SendMessage(hCombo, CB_GETEDITSEL, (WPARAM)&start, (WPARAM)&end); len = SendMessage(hCombo, CB_GETEDITSEL, 0,0); ok(LOWORD(len)==0, "Unexpected start position for selection %d\n", LOWORD(len)); - todo_wine ok(HIWORD(len)==6, "Unexpected end position for selection %d\n", HIWORD(len)); + ok(HIWORD(len)==6, "Unexpected end position for selection %d\n", HIWORD(len)); /* Now emulate a key press */ edit[0] = 0x00; SendMessage(hCombo, WM_CHAR, 'A', 0x1c0001); SendMessage(hCombo, WM_GETTEXT, sizeof(edit), (LPARAM)edit); - todo_wine ok(strcmp(edit, "A")==0, "Unexpected text retrieved %s\n", edit); + ok(strcmp(edit, "A")==0, "Unexpected text retrieved %s\n", edit); len = SendMessage(hCombo, CB_GETEDITSEL, 0,0); ok(LOWORD(len)==1, "Unexpected start position for selection %d\n", LOWORD(len)); @@ -489,7 +489,7 @@ static void test_editselection(void) SendMessage(hCombo, CB_GETEDITSEL, (WPARAM)&start, (WPARAM)&end); len = SendMessage(hCombo, CB_GETEDITSEL, 0,0); ok(LOWORD(len)==0, "Unexpected start position for selection %d\n", LOWORD(len)); - todo_wine ok(HIWORD(len)==6, "Unexpected end position for selection %d\n", HIWORD(len)); + ok(HIWORD(len)==6, "Unexpected end position for selection %d\n", HIWORD(len)); /* Now change the selection to the apparently invalid start -1, end -1 and show it means no selection (ie start -1) but cursor at end */ @@ -497,7 +497,7 @@ static void test_editselection(void) edit[0] = 0x00; SendMessage(hCombo, WM_CHAR, 'A', 0x1c0001); SendMessage(hCombo, WM_GETTEXT, sizeof(edit), (LPARAM)edit); - todo_wine ok(strcmp(edit, "Jason2A")==0, "Unexpected text retrieved %s\n", edit); + ok(strcmp(edit, "Jason2A")==0, "Unexpected text retrieved %s\n", edit); DestroyWindow(hCombo); }