Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/shell32/autocomplete.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-)
diff --git a/dlls/shell32/autocomplete.c b/dlls/shell32/autocomplete.c index 9bc617b..c5bc582 100644 --- a/dlls/shell32/autocomplete.c +++ b/dlls/shell32/autocomplete.c @@ -109,6 +109,14 @@ static void set_text_and_selection(IAutoCompleteImpl *This, HWND hwnd, WCHAR *te CallWindowProcW(proc, hwnd, EM_SETSEL, start, end); }
+static void hide_listbox(IAutoCompleteImpl *ac, HWND hwnd) +{ + /* hide the AutoComplete listbox but also reset its contents to avoid + memory use buildup for tons of edit controls with AutoComplete */ + ShowWindow(hwnd, SW_HIDE); + send_to_LB(ac, hwnd, LB_RESETCONTENT, 0, 0); +} + static void destroy_autocomplete_object(IAutoCompleteImpl *ac) { ac->hwndEdit = NULL; @@ -137,12 +145,12 @@ static LRESULT APIENTRY ACEditSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, { case CB_SHOWDROPDOWN: if (This->options & ACO_AUTOSUGGEST) - ShowWindow(This->hwndListBox, SW_HIDE); + hide_listbox(This, This->hwndListBox); break; case WM_KILLFOCUS: if ((This->options & ACO_AUTOSUGGEST) && ((HWND)wParam != This->hwndListBox)) { - ShowWindow(This->hwndListBox, SW_HIDE); + hide_listbox(This, This->hwndListBox); } return CallWindowProcW(This->wpOrigEditProc, hwnd, uMsg, wParam, lParam); case WM_KEYDOWN: @@ -181,7 +189,7 @@ static LRESULT APIENTRY ACEditSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam,
This->no_fwd_char = '\n'; /* CTRL+RETURN char */ if (This->options & ACO_AUTOSUGGEST) - ShowWindow(This->hwndListBox, SW_HIDE); + hide_listbox(This, This->hwndListBox); heap_free(hwndText); return 0; } @@ -196,13 +204,13 @@ static LRESULT APIENTRY ACEditSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, len = send_to_LB(This, hwndListBox, LB_GETTEXT, sel, (LPARAM)hwndText); set_text_and_selection(This, hwnd, hwndText, 0, len); This->no_fwd_char = '\r'; /* RETURN char */ - ShowWindow(hwndListBox, SW_HIDE); + hide_listbox(This, hwndListBox); heap_free(hwndText); return 0; } } } - ShowWindow(This->hwndListBox, SW_HIDE); + hide_listbox(This, This->hwndListBox); } break; case VK_UP: @@ -267,7 +275,7 @@ static LRESULT APIENTRY ACEditSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, edit_proc = edit_proc == ACEditSubclassProc ? This->wpOrigEditProc : edit_proc; len = CallWindowProcW(edit_proc, hwnd, WM_GETTEXTLENGTH, 0, 0); if ((This->options & ACO_AUTOSUGGEST) && len == 0) { - ShowWindow(This->hwndListBox, SW_HIDE); + hide_listbox(This, This->hwndListBox); return ret; } if (wParam != 0x16 /* ^V (paste) */) @@ -360,7 +368,7 @@ static LRESULT APIENTRY ACEditSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, SWP_SHOWWINDOW ); send_to_LB(This, This->hwndListBox, WM_SETREDRAW, TRUE, 0); } else { - ShowWindow(This->hwndListBox, SW_HIDE); + hide_listbox(This, This->hwndListBox); } } return ret; @@ -400,7 +408,7 @@ static LRESULT APIENTRY ACLBoxSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, if ((msg = heap_alloc((len + 1)*sizeof(WCHAR)))) { 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); + hide_listbox(This, hwnd); heap_free(msg); } break;