From a378b7b4bea370a6aa1dca8b88f84e2cffcfa1e6 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 26 Aug 2023 18:20:32 +0200 Subject: [PATCH] Remove special wxFindReplaceDialog hack from wxGUIEventLoop Don't call IsDialogMessage() for any unknown windows, this is not needed any longer now that we recognize wxFindReplaceDialog HWND as ours (see the previous commit) and that its MSWProcessMessage() works correctly (done in this one). Removing this IsDialogMessage() call still allows TAB navigation to work in the "Find" dialog but prevents us from processing unknown messages for unknown windows, which might have unwatned consequences. --- include/wx/msw/fdrepdlg.h | 2 ++ src/msw/evtloop.cpp | 10 +--------- src/msw/fdrepdlg.cpp | 13 +++++++++++++ 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/include/wx/msw/fdrepdlg.h b/include/wx/msw/fdrepdlg.h index 5884351cd4..9ccf2a6e12 100644 --- a/include/wx/msw/fdrepdlg.h +++ b/include/wx/msw/fdrepdlg.h @@ -41,6 +41,8 @@ public: virtual void SetTitle( const wxString& title) override; virtual wxString GetTitle() const override; + virtual bool MSWProcessMessage(WXMSG* pMsg) override; + protected: virtual void DoGetSize(int *width, int *height) const override; virtual void DoGetClientSize(int *width, int *height) const override; diff --git a/src/msw/evtloop.cpp b/src/msw/evtloop.cpp index 34018e8bee..cda02f3b5f 100644 --- a/src/msw/evtloop.cpp +++ b/src/msw/evtloop.cpp @@ -79,15 +79,7 @@ bool wxGUIEventLoop::PreProcessMessage(WXMSG *msg) } if ( !wndThis ) - { - // this may happen if the event occurred in a standard modeless dialog (the - // only example of which I know of is the find/replace dialog) - then call - // IsDialogMessage() to make TAB navigation in it work - - // NOTE: IsDialogMessage() just eats all the messages (i.e. returns true for - // them) if we call it for the control itself - return hwnd && ::IsDialogMessage(hwnd, msg) != 0; - } + return false; } if ( !AllowProcessing(wndThis) ) diff --git a/src/msw/fdrepdlg.cpp b/src/msw/fdrepdlg.cpp index b5890279de..c50ff773c9 100644 --- a/src/msw/fdrepdlg.cpp +++ b/src/msw/fdrepdlg.cpp @@ -446,6 +446,19 @@ wxString wxFindReplaceDialog::GetTitle() const return m_title; } +// ---------------------------------------------------------------------------- +// wxFindReplaceDialog message handling +// ---------------------------------------------------------------------------- + +bool wxFindReplaceDialog::MSWProcessMessage(WXMSG* pMsg) +{ + // The base class MSWProcessMessage() doesn't work for us because we don't + // have wxTAB_TRAVERSAL style, but then we don't need it anyhow: as this + // dialog only ever contains standard controls, just using the standard + // function is enough to make TAB navigation work in it. + return m_hWnd && ::IsDialogMessage(m_hWnd, pMsg); +} + // ---------------------------------------------------------------------------- // wxFindReplaceDialog position/size // ----------------------------------------------------------------------------