I've solved the issue by overriding OnCmdMsg
in the CMDIChildWnd
. Now, after trying to dispatch a message the usual way, the CMDIChildWnd
also tries to dispatch the message to its inactive views and stops after one of them handles the message.
BOOL CShowLessonsChildFrame::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo)
{
CPushRoutingFrame push(this);
// pump through current view FIRST
CView* pView = GetActiveView();
if (pView != NULL && pView->OnCmdMsg(nID, nCode, pExtra, pHandlerInfo))
return TRUE;
// then pump through frame
if (CWnd::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo))
return TRUE;
// last but not least, pump through app
CWinApp* pApp = AfxGetApp();
if (pApp != NULL && pApp->OnCmdMsg(nID, nCode, pExtra, pHandlerInfo))
return TRUE;
// Now try to dispatch the message to inactive windows and see if
// one of them handles the message
for(UINT id = AFX_IDW_PANE_FIRST; id <= AFX_IDW_PANE_LAST; id++)
{
CWnd *pWnd = GetDescendantWindow(id, TRUE);
if(pWnd && pWnd != GetActiveView()
&& pWnd->OnCmdMsg(nID, nCode, pExtra, pHandlerInfo))
return TRUE;
}
return FALSE;
}