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).
This commit is contained in:
Vadim Zeitlin
2017-12-11 22:06:13 +01:00
parent 3960e630f1
commit 636219bd35

View File

@@ -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 *>(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<wxGUIEventLoop *>(wxEventLoop::GetActive());
wxGUIEventLoop evtLoopStd;
if ( !evtLoop )
evtLoop = &evtLoopStd;
if ( evtLoop->PreProcessMessage(msg) )
return TRUE;
return BaseApp::PreTranslateMessage(msg);