Jason Edmeades : user32: Preselect all editbox text when combo gets focus.
Alexandre Julliard
julliard at winehq.org
Mon Jan 25 11:21:18 CST 2010
Module: wine
Branch: master
Commit: f27b032d50b720abae8a971e3eeac382f132d38b
URL: http://source.winehq.org/git/wine.git/?a=commit;h=f27b032d50b720abae8a971e3eeac382f132d38b
Author: Jason Edmeades <jason.edmeades at googlemail.com>
Date: Sun Jan 24 12:56:11 2010 -0800
user32: Preselect all editbox text when combo gets focus.
---
dlls/user32/combo.c | 10 ++++++++--
dlls/user32/controls.h | 1 +
dlls/user32/tests/combo.c | 8 ++++----
3 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/dlls/user32/combo.c b/dlls/user32/combo.c
index 85e372a..d31f17e 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 8275ee5..2054922 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 b0f7488..bee685c 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);
}
More information about the wine-cvs
mailing list