From 91dda33431ca82e6ee95633287b82ef586f072bd Mon Sep 17 00:00:00 2001 From: James Tabor Date: Sat, 29 Jul 2017 01:59:07 +0000 Subject: [PATCH] [User32] - Patch by MudHead : Combobox sends a message to the deselect the text when focus is lost. CORE-10266 #resolve svn path=/trunk/; revision=75436 --- reactos/sdk/include/reactos/undocuser.h | 1 + reactos/win32ss/user/user32/controls/combo.c | 13 +++++++++++ reactos/win32ss/user/user32/controls/edit.c | 23 ++++++++++++++++++++ 3 files changed, 37 insertions(+) diff --git a/reactos/sdk/include/reactos/undocuser.h b/reactos/sdk/include/reactos/undocuser.h index 70f60f4a266..dea855684cf 100644 --- a/reactos/sdk/include/reactos/undocuser.h +++ b/reactos/sdk/include/reactos/undocuser.h @@ -46,6 +46,7 @@ extern "C" { #define WM_NCUAHDRAWFRAME 0x000000AF #define WM_SYSTIMER 0x00000118 #define WM_LBTRACKPOINT 0x00000131 +#define WM_CBLOSTTEXTFOCUS 0x00000167 #define LB_CARETON 0x000001a3 #define LB_CARETOFF 0x000001a4 #define MN_SETHMENU 0x000001e0 diff --git a/reactos/win32ss/user/user32/controls/combo.c b/reactos/win32ss/user/user32/controls/combo.c index d12e6dcbd2d..8ec5bd99946 100644 --- a/reactos/win32ss/user/user32/controls/combo.c +++ b/reactos/win32ss/user/user32/controls/combo.c @@ -2260,6 +2260,19 @@ LRESULT WINAPI ComboWndProc_common( HWND hwnd, UINT message, WPARAM wParam, LPAR NtUserInvalidateRect(lphc->self, &lphc->textRect, TRUE); } break; + + case WM_CBLOSTTEXTFOCUS: /* undocumented message - deselects the text when focus is lost */ + { + if (lphc->hWndEdit != NULL) + { + SendMessage(lphc->self, WM_LBUTTONUP, 0, 0xFFFFFFFF); + SendMessage(lphc->hWndEdit, EM_SETSEL, 0, 0); + lphc->wState &= ~CBF_FOCUSED; + CB_NOTIFY(lphc, CBN_KILLFOCUS); + } + } + return TRUE; + #endif default: diff --git a/reactos/win32ss/user/user32/controls/edit.c b/reactos/win32ss/user/user32/controls/edit.c index 99205864d9c..f62ac9263c3 100644 --- a/reactos/win32ss/user/user32/controls/edit.c +++ b/reactos/win32ss/user/user32/controls/edit.c @@ -3628,6 +3628,28 @@ static LRESULT EDIT_WM_KeyDown(EDITSTATE *es, INT key) */ static LRESULT EDIT_WM_KillFocus(EDITSTATE *es) { +#ifdef __REACTOS__ + HWND hCombo; + LONG lStyles; + + es->flags &= ~EF_FOCUSED; + DestroyCaret(); + if(!(es->style & ES_NOHIDESEL)) + EDIT_InvalidateText(es, es->selection_start, es->selection_end); + + /* throw away left over scroll when we lose focus */ + es->wheelDeltaRemainder = 0; + + if (es->hwndListBox == NULL) + EDIT_NOTIFY_PARENT(es, EN_KILLFOCUS); + else + { /* send the undocumented WM_CBLOSTTEXTFOCUS message to combobox */ + hCombo = GetParent(es->hwndSelf); + lStyles = GetWindowLong(hCombo, GWL_STYLE); + if ((lStyles & CBS_DROPDOWN) || (lStyles & CBS_SIMPLE)) + SendMessage(hCombo, WM_CBLOSTTEXTFOCUS, 0, 0); + } +#else es->flags &= ~EF_FOCUSED; DestroyCaret(); if(!(es->style & ES_NOHIDESEL)) @@ -3635,6 +3657,7 @@ static LRESULT EDIT_WM_KillFocus(EDITSTATE *es) EDIT_NOTIFY_PARENT(es, EN_KILLFOCUS); /* throw away left over scroll when we lose focus */ es->wheelDeltaRemainder = 0; +#endif return 0; }