From 4179375f3ebcf59fe3fcf7bc552c0bc7fb0de783 Mon Sep 17 00:00:00 2001 From: AliKet Date: Sat, 17 Feb 2018 14:49:38 +0100 Subject: [PATCH] Add custom auto-completer support to wxMSW wxComboBox too Custom auto-completers didn't work for wxComboBox as it didn't generate wxEVT_AFTER_CHAR event that the completion code in wxTextEntry relies on to make them work. Add this event generation to wxComboBox::MSWProcessEditMsg() to fix this. Closes https://github.com/wxWidgets/wxWidgets/pull/732 --- src/msw/combobox.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/msw/combobox.cpp b/src/msw/combobox.cpp index 45c9be0ffd34..e2072b31cc37 100644 --- a/src/msw/combobox.cpp +++ b/src/msw/combobox.cpp @@ -280,7 +280,25 @@ bool wxComboBox::MSWProcessEditMsg(WXUINT msg, WXWPARAM wParam, WXLPARAM lParam) // For all the messages forwarded from the edit control the result is not // used and 0 must be returned if the message is handled. WXLRESULT result; - return MSWHandleMessage(&result, msg, wParam, lParam); + bool processed = MSWHandleMessage(&result, msg, wParam, lParam); + + // Special hack for WM_CHAR needed by wxTextEntry auto-completion support. + if ( !processed && msg == WM_CHAR ) + { + // Here we reproduce what MSWDefWindowProc() does for this window + // itself, but for the EDIT window. + ::CallWindowProc(CASTWNDPROC gs_wndprocEdit, (HWND)GetEditHWND(), + msg, wParam, lParam); + + // Send the event allowing completion code to do its thing. + wxKeyEvent event(CreateCharEvent(wxEVT_AFTER_CHAR, wParam, lParam)); + HandleWindowEvent(event); + + // Default window proc was already called, don't call it again. + processed = true; + } + + return processed; } bool wxComboBox::MSWCommand(WXUINT param, WXWORD id)