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
This commit is contained in:
Vadim Zeitlin
2013-05-04 23:59:51 +00:00
parent bbde2164ac
commit 80dcb89812
2 changed files with 13 additions and 17 deletions

View File

@@ -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

View File

@@ -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)