From 636219bd355bd64a5b1507e4d37e033fe50969f3 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 11 Dec 2017 22:06:13 +0100 Subject: [PATCH] Always pre-process messages for wx windows in mixed wx/MFC apps Still use the active event loop if there is one, just in case it customizes messages pre-processing, but fall back on the standard pre-processing code even if there is no active wx event loop and we're only running the MFC one, as without doing this there are just too many things that don't work (e.g. menu accelerators didn't work at all in mixed wx/MFC applications previously). --- include/wx/msw/mfc.h | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/include/wx/msw/mfc.h b/include/wx/msw/mfc.h index 894918f194..f3fc23e44d 100644 --- a/include/wx/msw/mfc.h +++ b/include/wx/msw/mfc.h @@ -79,12 +79,19 @@ public: return BaseApp::ExitInstance(); } - // Override this to provide wxWidgets message loop compatibility + // Override this to provide messages pre-processing for wxWidgets windows. BOOL PreTranslateMessage(MSG *msg) wxOVERRIDE { - wxEventLoop * const - evtLoop = static_cast(wxEventLoop::GetActive()); - if ( evtLoop && evtLoop->PreProcessMessage(msg) ) + // Use the current event loop if there is one, or just fall back to the + // standard one otherwise, but make sure we pre-process messages in any + // case as otherwise many things would break (e.g. keyboard + // accelerators). + wxGUIEventLoop* + evtLoop = static_cast(wxEventLoop::GetActive()); + wxGUIEventLoop evtLoopStd; + if ( !evtLoop ) + evtLoop = &evtLoopStd; + if ( evtLoop->PreProcessMessage(msg) ) return TRUE; return BaseApp::PreTranslateMessage(msg);