Command routing problem with CMFCMenuBar
Posted on 2008-10-27
when I create a new MDI application using extended features (especially 'menu bar') from MFC Feature Pack for VS 2008 I encounter following problem: When the view has set the mouse capture (SetCapture) commands from menues with shortcut are executed allthough they shouldn't be available.
For testing this I just created a new MDI project using a menu bar and implemented WM_LBUTTONUP/DOWN handlers to set capture like this:
void CTestView::OnLButtonDown(UINT nFlags, CPoint point)
::SetCapture( m_hWnd );
void CTestView::OnLButtonUp(UINT nFlags, CPoint point)
::SetCapture( NULL );
Now, while mouse button is pressed the view captures the mouse input, but I'm able to i.e. open the 'Open File' dialog by pressing the shortcut 'CTRL-O'. If I do the same in an application without CMFCMenuBar this doesn't happen (I can simulate this by simply commenting out all lines in my CMainFrame class which handle 'm_wndMenuBar' creation/docking).
I debugged the problem and could see that in both cases a call to '::TranslateAccelerator' is done in 'CMDIFrameWnd::PreTranslateMessage', in case I use CMFCMenuBar this causes the 'ID_FILE_OPEN' handler is called from here, if I don't use CMFCMenuBar this doesn't happen.
Does anybody know about a possibility to get that 'old-style' kind of command routing with use of CMFCMenuBar?
Thanks in advance,