=?UTF-8?Q?Gabriel=20Iv=C4=83ncescu=20?=: shell32/autocomplete: Send some messages directly to the edit control's procedure.

Alexandre Julliard julliard at winehq.org
Mon Sep 24 15:48:23 CDT 2018


Module: wine
Branch: master
Commit: 087c24dfdc4496ed983f44eb19934e482cf7413a
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=087c24dfdc4496ed983f44eb19934e482cf7413a

Author: Gabriel Ivăncescu <gabrielopcode at gmail.com>
Date:   Sat Sep 22 17:53:43 2018 +0300

shell32/autocomplete: Send some messages directly to the edit control's procedure.

Send some of the messages directly to the edit control's window procedure
to match Windows behavior and to be able to process WM_SETTEXT.

Signed-off-by: Gabriel Ivăncescu <gabrielopcode at gmail.com>
Signed-off-by: Huw Davies <huw at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/shell32/autocomplete.c | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/dlls/shell32/autocomplete.c b/dlls/shell32/autocomplete.c
index 048a47f..2f63d88 100644
--- a/dlls/shell32/autocomplete.c
+++ b/dlls/shell32/autocomplete.c
@@ -100,6 +100,14 @@ static inline IAutoCompleteImpl *impl_from_IAutoCompleteDropDown(IAutoCompleteDr
     return CONTAINING_RECORD(iface, IAutoCompleteImpl, IAutoCompleteDropDown_iface);
 }
 
+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 behavior */
+    WNDPROC proc = ac->wpOrigEditProc;
+    if (CallWindowProcW(proc, hwnd, WM_SETTEXT, 0, (LPARAM)text))
+        CallWindowProcW(proc, hwnd, EM_SETSEL, start, end);
+}
+
 static size_t format_quick_complete(WCHAR *dst, const WCHAR *qc, const WCHAR *str, size_t str_len)
 {
     /* Replace the first %s directly without using snprintf, to avoid
@@ -142,8 +150,7 @@ static void autoappend_str(IAutoCompleteImpl *ac, WCHAR *text, UINT len, WCHAR *
     }
     else tmp = str;
 
-    SendMessageW(hwnd, WM_SETTEXT, 0, (LPARAM)tmp);
-    SendMessageW(hwnd, EM_SETSEL, len, size - 1);
+    set_text_and_selection(ac, hwnd, tmp, len, size - 1);
     if (tmp != str)
         heap_free(tmp);
 }
@@ -256,8 +263,7 @@ static LRESULT ACEditSubclassProc_KeyDown(IAutoCompleteImpl *ac, HWND hwnd, UINT
                 if ((buf = heap_alloc(sz * sizeof(WCHAR))))
                 {
                     len = format_quick_complete(buf, ac->quickComplete, text, len);
-                    SendMessageW(hwnd, WM_SETTEXT, 0, (LPARAM)buf);
-                    SendMessageW(hwnd, EM_SETSEL, 0, len);
+                    set_text_and_selection(ac, hwnd, buf, 0, len);
                     heap_free(buf);
                 }
 
@@ -309,16 +315,13 @@ static LRESULT ACEditSubclassProc_KeyDown(IAutoCompleteImpl *ac, HWND hwnd, UINT
                     if (!(msg = heap_alloc((len + 1) * sizeof(WCHAR))))
                         return 0;
                     len = SendMessageW(ac->hwndListBox, LB_GETTEXT, sel, (LPARAM)msg);
-                    SendMessageW(hwnd, WM_SETTEXT, 0, (LPARAM)msg);
-                    SendMessageW(hwnd, EM_SETSEL, len, len);
+                    set_text_and_selection(ac, hwnd, msg, len, len);
                     heap_free(msg);
                 }
                 else
                 {
-                    UINT len;
-                    SendMessageW(hwnd, WM_SETTEXT, 0, (LPARAM)ac->txtbackup);
-                    len = strlenW(ac->txtbackup);
-                    SendMessageW(hwnd, EM_SETSEL, len, len);
+                    UINT len = strlenW(ac->txtbackup);
+                    set_text_and_selection(ac, hwnd, ac->txtbackup, len, len);
                 }
                 return 0;
             }
@@ -409,8 +412,7 @@ static LRESULT APIENTRY ACLBoxSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam,
             if (!(msg = heap_alloc((len + 1) * sizeof(WCHAR))))
                 break;
             len = SendMessageW(hwnd, LB_GETTEXT, sel, (LPARAM)msg);
-            SendMessageW(This->hwndEdit, WM_SETTEXT, 0, (LPARAM)msg);
-            SendMessageW(This->hwndEdit, EM_SETSEL, 0, len);
+            set_text_and_selection(This, This->hwndEdit, msg, 0, len);
             ShowWindow(hwnd, SW_HIDE);
             heap_free(msg);
             break;




More information about the wine-cvs mailing list