From: Gabriel Ivăncescu Subject: [PATCH v2 6/8] shell32/autocomplete: Send messages directly to the AutoComplete listbox Message-Id: Date: Thu, 20 Sep 2018 14:55:39 +0300 In-Reply-To: References: Signed-off-by: Gabriel Ivăncescu --- Split from previous patch, reduces needless overhead. dlls/shell32/autocomplete.c | 41 +++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/dlls/shell32/autocomplete.c b/dlls/shell32/autocomplete.c index 3326e31..d03feb5 100644 --- a/dlls/shell32/autocomplete.c +++ b/dlls/shell32/autocomplete.c @@ -108,6 +108,11 @@ static inline WNDPROC get_edit_proc(IAutoCompleteImpl *ac, HWND hwnd) return (edit_proc == ACEditSubclassProc) ? ac->wpOrigEditProc : edit_proc; } +static inline LRESULT send_to_LB(IAutoCompleteImpl *ac, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + return CallWindowProcW(ac->wpOrigLBoxProc, hwnd, msg, wParam, lParam); +} + static void set_text_and_selection(IAutoCompleteImpl *ac, HWND hwnd, WCHAR *text, WPARAM start, LPARAM end) { /* Send it directly to the edit control to match Windows XP behavior */ @@ -186,7 +191,7 @@ static void autocomplete_text(IAutoCompleteImpl *ac, HWND hwnd, enum autoappend_ if (len + 1 != size) text = heap_realloc(text, (len + 1) * sizeof(WCHAR)); - SendMessageW(ac->hwndListBox, LB_RESETCONTENT, 0, 0); + send_to_LB(ac, ac->hwndListBox, LB_RESETCONTENT, 0, 0); /* Set txtbackup to point to text itself (which must not be released) */ heap_free(ac->txtbackup); @@ -215,7 +220,7 @@ static void autocomplete_text(IAutoCompleteImpl *ac, HWND hwnd, enum autoappend_ } if (ac->options & ACO_AUTOSUGGEST) - SendMessageW(ac->hwndListBox, LB_ADDSTRING, 0, (LPARAM)strs); + send_to_LB(ac, ac->hwndListBox, LB_ADDSTRING, 0, (LPARAM)strs); cpt++; } @@ -228,8 +233,8 @@ static void autocomplete_text(IAutoCompleteImpl *ac, HWND hwnd, enum autoappend_ if (cpt) { RECT r; - UINT height = SendMessageW(ac->hwndListBox, LB_GETITEMHEIGHT, 0, 0); - SendMessageW(ac->hwndListBox, LB_CARETOFF, 0, 0); + UINT height = send_to_LB(ac, ac->hwndListBox, LB_GETITEMHEIGHT, 0, 0); + send_to_LB(ac, ac->hwndListBox, LB_CARETOFF, 0, 0); GetWindowRect(hwnd, &r); SetParent(ac->hwndListBox, HWND_DESKTOP); /* It seems that Windows XP displays 7 lines at most @@ -310,24 +315,24 @@ static LRESULT ACEditSubclassProc_KeyDown(IAutoCompleteImpl *ac, HWND hwnd, UINT else { INT count, sel; - count = SendMessageW(ac->hwndListBox, LB_GETCOUNT, 0, 0); + count = send_to_LB(ac, ac->hwndListBox, LB_GETCOUNT, 0, 0); /* Change the selection */ - sel = SendMessageW(ac->hwndListBox, LB_GETCURSEL, 0, 0); + sel = send_to_LB(ac, ac->hwndListBox, LB_GETCURSEL, 0, 0); if (wParam == VK_UP) sel = ((sel - 1) < -1) ? count - 1 : sel - 1; else sel = ((sel + 1) >= count) ? -1 : sel + 1; - SendMessageW(ac->hwndListBox, LB_SETCURSEL, sel, 0); + send_to_LB(ac, ac->hwndListBox, LB_SETCURSEL, sel, 0); if (sel >= 0) { WCHAR *msg; UINT len; - len = SendMessageW(ac->hwndListBox, LB_GETTEXTLEN, sel, 0); + len = send_to_LB(ac, ac->hwndListBox, LB_GETTEXTLEN, sel, 0); if (!(msg = heap_alloc((len + 1) * sizeof(WCHAR)))) return 0; - len = SendMessageW(ac->hwndListBox, LB_GETTEXT, sel, (LPARAM)msg); + len = send_to_LB(ac, ac->hwndListBox, LB_GETTEXT, sel, (LPARAM)msg); set_text_and_selection(ac, hwnd, msg, len, len); heap_free(msg); } @@ -414,23 +419,23 @@ static LRESULT APIENTRY ACLBoxSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, switch (uMsg) { case WM_MOUSEMOVE: - sel = SendMessageW(hwnd, LB_ITEMFROMPOINT, 0, lParam); - SendMessageW(hwnd, LB_SETCURSEL, sel, 0); + sel = send_to_LB(This, hwnd, LB_ITEMFROMPOINT, 0, lParam); + send_to_LB(This, hwnd, LB_SETCURSEL, sel, 0); break; case WM_LBUTTONDOWN: - sel = SendMessageW(hwnd, LB_GETCURSEL, 0, 0); + sel = send_to_LB(This, hwnd, LB_GETCURSEL, 0, 0); if (sel < 0) break; - len = SendMessageW(This->hwndListBox, LB_GETTEXTLEN, sel, 0); + len = send_to_LB(This, hwnd, LB_GETTEXTLEN, sel, 0); if (!(msg = heap_alloc((len + 1) * sizeof(WCHAR)))) break; - len = SendMessageW(hwnd, LB_GETTEXT, sel, (LPARAM)msg); + len = send_to_LB(This, hwnd, LB_GETTEXT, sel, (LPARAM)msg); set_text_and_selection(This, This->hwndEdit, msg, 0, len); ShowWindow(hwnd, SW_HIDE); heap_free(msg); break; default: - return CallWindowProcW(This->wpOrigLBoxProc, hwnd, uMsg, wParam, lParam); + return send_to_LB(This, hwnd, uMsg, wParam, lParam); } return 0; } @@ -749,14 +754,14 @@ static HRESULT WINAPI IAutoCompleteDropDown_fnGetDropDownStatus( if (dropped) { int sel; - sel = SendMessageW(This->hwndListBox, LB_GETCURSEL, 0, 0); + sel = send_to_LB(This, This->hwndListBox, LB_GETCURSEL, 0, 0); if (sel >= 0) { DWORD len; - len = SendMessageW(This->hwndListBox, LB_GETTEXTLEN, sel, 0); + len = send_to_LB(This, This->hwndListBox, LB_GETTEXTLEN, sel, 0); *ppwszString = CoTaskMemAlloc((len+1)*sizeof(WCHAR)); - SendMessageW(This->hwndListBox, LB_GETTEXT, sel, (LPARAM)*ppwszString); + send_to_LB(This, This->hwndListBox, LB_GETTEXT, sel, (LPARAM)*ppwszString); } else *ppwszString = NULL; -- 1.9.1