From 80dcb89812d84f41567a69ff83769b26ab519468 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 4 May 2013 23:59:51 +0000 Subject: [PATCH] Forward events to active child at MSW, not wx, level in wxMDIParentFrame. We want to handle menu (and toolbar) events in the active MDI child before handling them in the parent frame itself and the existing code achieved this by forwarding wxEVT_MENU events at wx event processing level to the active child. However this was not enough as the underlying MSW WM_COMMAND message was still sent to the parent frame only and this could result in wx event not being generated at all if the parent frame had a disabled menu item with the same ID as (an enabled) item in the child frame, see #14314. So forward WM_COMMAND directly to ensure that the correct window gets the event in the first place. And this makes wxEVT_MENU forwarding in TryBefore() unnecessary. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@73927 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/msw/mdi.h | 3 --- src/msw/mdi.cpp | 27 +++++++++++++-------------- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/include/wx/msw/mdi.h b/include/wx/msw/mdi.h index caf235fd56..afef0664a4 100644 --- a/include/wx/msw/mdi.h +++ b/include/wx/msw/mdi.h @@ -110,9 +110,6 @@ public: #endif // wxUSE_MENUS protected: - // override to pass menu/toolbar events to the active child first - virtual bool TryBefore(wxEvent& event); - #if wxUSE_MENUS_NATIVE virtual void InternalSetMenuBar(); #endif // wxUSE_MENUS_NATIVE diff --git a/src/msw/mdi.cpp b/src/msw/mdi.cpp index db1997bdd6..6ecd832ea5 100644 --- a/src/msw/mdi.cpp +++ b/src/msw/mdi.cpp @@ -577,6 +577,19 @@ WXLRESULT wxMDIParentFrame::MSWWindowProc(WXUINT message, MSWDefWindowProc(message, wParam, lParam); processed = true; } + else // Not a system command. + { + // Menu (and toolbar) events should be sent to the active + // child first and only be processed by the parent frame if + // they're not handled there. + if ( wxMDIChildFrame* child = GetActiveChild() ) + { + processed = child->MSWHandleMessage(&rc, + message, + wParam, + lParam); + } + } } break; @@ -695,20 +708,6 @@ void wxMDIParentFrame::OnMDICommand(wxCommandEvent& event) #endif // wxUSE_MENUS -bool wxMDIParentFrame::TryBefore(wxEvent& event) -{ - // menu (and toolbar) events should be sent to the active child frame - // first, if any - if ( event.GetEventType() == wxEVT_MENU ) - { - wxMDIChildFrame * const child = GetActiveChild(); - if ( child && child->ProcessWindowEventLocally(event) ) - return true; - } - - return wxMDIParentFrameBase::TryBefore(event); -} - WXLRESULT wxMDIParentFrame::MSWDefWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam) -- 2.45.2