Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS Tech Support » OnCmdMsg routing problems Collapse All
Subject Author Date
Scott Moore Oct 27, 2008 - 7:19 AM

I have an application similiar in design to your SDI_DynamicBars application.  When I run your SDI_DynamicBars sample, I noticed the Edit menu (Cut/Copy/Paste) is always greyed out.  Yet the popup menus seem to be working correctly.


I have the same problem in my application.  Command message routing does not seem to work correctly for all the dynamic bars, especially floating bars.  My edit menu does not seem to get command messages from the focus window.


I copied the CMainFrame::OnCmdMsg code from your sample application and it did not fix my menu issues.  Can you explain how to fix command routing when using dynamic bars?

Technical Support Oct 27, 2008 - 2:13 PM

Your application is responsible for command routing into windows inside control bars both in MFC-based and Prof-UIS-based applications. In the case of SDI_DynamicBars sample the CMainFrame::OnCmdMsg() method should have the following source code:

BOOL CMainFrame::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo)
{
            if( CExtDynamicBarSite::OnCmdMsg( nID, nCode, pExtra, pHandlerInfo ) )
                        return TRUE;

            if( nID == ID_EDIT_COPY || nID == ID_EDIT_CUT || nID == ID_EDIT_PASTE )
            {
                        HWND hWndFocus = ::GetFocus();
                        if( hWndFocus != NULL )
                        {
                                    CWnd * pWnd = CWnd::FromHandlePermanent( hWndFocus );
                                    if(                     pWnd != NULL
                                                &&        pWnd->OnCmdMsg(nID, nCode, pExtra, pHandlerInfo )
                                                )
                                                return TRUE;
                        }
            }
            
            if( m_wndView.OnCmdMsg(nID, nCode, pExtra, pHandlerInfo ) )
                        return TRUE;

            return CExtNCW < CFrameWnd > :: OnCmdMsg( nID, nCode, pExtra, pHandlerInfo );
}
This makes the ID_EDIT_COPY command in a menu bar working correctly with edit controls in dynamic control bars. It will be enabled only if some edit control is focused and some text range is selected in it. The ID_EDIT_CUT and ID_EDIT_PASTE commands will remain disabled because all these editors with colored backgrounds are read-only.