From 510ae4e0b44f78ec76f474c61290aadd1a8313e0 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 9 Jan 2015 03:30:13 +0000 Subject: [PATCH] Send deactivation events to MDI children frame in wxMSW too. For some reason, the code only forwarded activation events to the current MDI child, but not the deactivation ones. And even though this was literally always the case (the check for the event being the activation one is there since r9), it is clearly wrong as the focus restoring code in wxTopLevelWindow in wxMSW doesn't work if the focus hadn't been previously saved. This fix hopefully completes the changes started by r78340 and r78341 and ensures that the focus is always properly restored to the last focused window inside an MDI child. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@78361 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/mdi.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/msw/mdi.cpp b/src/msw/mdi.cpp index 7d26bdce8c..705c9af788 100644 --- a/src/msw/mdi.cpp +++ b/src/msw/mdi.cpp @@ -669,14 +669,12 @@ bool wxMDIParentFrame::HandleActivate(int state, bool minimized, WXHWND activate processed = !m_activationNotHandled; } - // If this window is an MDI parent, we must also send an OnActivate message - // to the current child. - if ( GetActiveChild() && - ((state == WA_ACTIVE) || (state == WA_CLICKACTIVE)) ) + // Also generate the (de)activation event for the current child, if any, to + // allow updating its state and, in particular, remembering or restoring + // its last focused window. + if ( GetActiveChild() ) { - wxActivateEvent event(wxEVT_ACTIVATE, true, GetActiveChild()->GetId()); - event.SetEventObject( GetActiveChild() ); - if ( GetActiveChild()->HandleWindowEvent(event) ) + if ( GetActiveChild()->HandleActivate(state, minimized, activate) ) processed = true; }