From: Gabriel Ivăncescu Subject: [PATCH 11/17] shell32/autocomplete: Remove flicker while redrawing the AutoComplete listbox Message-Id: <2e6bf3e31dd9c37b7f82a821b369251a8fbedc89.1536163731.git.gabrielopcode@gmail.com> Date: Wed, 5 Sep 2018 19:13:13 +0300 In-Reply-To: <695190c8471230e6a87e237a7c4a86e3281525b8.1536163731.git.gabrielopcode@gmail.com> References: <695190c8471230e6a87e237a7c4a86e3281525b8.1536163731.git.gabrielopcode@gmail.com> Signed-off-by: Gabriel Ivăncescu --- For some reason the continuous SetParent made it flicker badly when it changed its contents, so just set it once at listbox creation. It also removes unnecessary overhead at the same time. dlls/shell32/autocomplete.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/dlls/shell32/autocomplete.c b/dlls/shell32/autocomplete.c index b71cbc0..1678d87 100644 --- a/dlls/shell32/autocomplete.c +++ b/dlls/shell32/autocomplete.c @@ -263,8 +263,6 @@ static LRESULT APIENTRY ACEditSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, if (len+1 != old_len) hwndText = heap_realloc(hwndText, len+1); - send_to_LB(This, This->hwndListBox, LB_RESETCONTENT, 0, 0); - /* Set txtbackup to point to hwndText itself (which must not be released) */ heap_free(This->txtbackup); This->txtbackup = hwndText; @@ -272,6 +270,10 @@ static LRESULT APIENTRY ACEditSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, if (!displayall && !len) return ret; + if (This->options & ACO_AUTOSUGGEST) { + send_to_LB(This, This->hwndListBox, WM_SETREDRAW, FALSE, 0); + send_to_LB(This, This->hwndListBox, LB_RESETCONTENT, 0, 0); + } IEnumString_Reset(This->enumstr); for(cpt = 0;;) { LPOLESTR strs = NULL; @@ -321,12 +323,12 @@ static LRESULT APIENTRY ACEditSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, UINT height = send_to_LB(This, This->hwndListBox, LB_GETITEMHEIGHT, 0, 0); send_to_LB(This, This->hwndListBox, LB_CARETOFF, 0, 0); GetWindowRect(hwnd, &r); - SetParent(This->hwndListBox, HWND_DESKTOP); /* It seems that Windows XP displays 7 lines at most and otherwise displays a vertical scroll bar */ SetWindowPos(This->hwndListBox, HWND_TOP, r.left, r.bottom + 1, r.right - r.left, height*min(cpt+1, 7), SWP_SHOWWINDOW ); + send_to_LB(This, This->hwndListBox, WM_SETREDRAW, TRUE, 0); } else { ShowWindow(This->hwndListBox, SW_HIDE); } @@ -393,6 +395,7 @@ static void create_listbox(IAutoCompleteImpl *This) if (This->hwndListBox) { This->wpOrigLBoxProc = (WNDPROC) SetWindowLongPtrW( This->hwndListBox, GWLP_WNDPROC, (LONG_PTR) ACLBoxSubclassProc); SetWindowLongPtrW( This->hwndListBox, GWLP_USERDATA, (LONG_PTR)This); + SetParent(This->hwndListBox, HWND_DESKTOP); } else This->options &= ~ACO_AUTOSUGGEST; -- 1.9.1