user32: Preselect all editbox text when combo gets focus.

This commit is contained in:
Jason Edmeades 2010-01-24 12:56:11 -08:00 committed by Alexandre Julliard
parent 0641192b52
commit f27b032d50
3 changed files with 13 additions and 6 deletions

View File

@ -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;

View File

@ -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 */

View File

@ -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);
}