具体见图:
图片中代码不太清楚,贴在这里:
BOOL CMainFrame::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo)
{
if (pDoc)
return pDoc->RouteCmdAllViews(GetActiveView(), nID, nCode, pExtra, pHandlerInfo);
if(CFrameWnd::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo))
return TRUE;
return FALSE;
}
BOOL CDemoDoc::RouteCmdAllViews(CView* pActiveView, UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo)
{
POSITION pos = GetFirstViewPosition();
CView* pNextView = NULL;
while (pos)
{
pNextView = GetNextView(pos); //pos is a reference, will be set to NULL when final view returned
if (pNextView != pActiveView)
{
if (pNextView->OnCmdMsg( nID, nCode, pExtra, pHandlerInfo))
return TRUE;
}
}
return FALSE;
}