Cropped menu bar RRS feed

  • Question

  • We have recently implemented ribbon interface using CMFCRibbonBar, so our application can switch between ribbon interface and menu/toolbar interface. We found that on some monitors menu bar is cropped after switching from ribbon interface to menu/toolbar interface.

    Our application can start from either ribbon interface or menu/toolbar interface. If we start the application from menu/toolbar interface, menu bar looks OK.

    Could you please let me know how to fix the cropped menu bar?

    Thanks in advance.

    Thursday, June 13, 2019 1:33 PM

All replies

  • Its not clear from the image if the menu height is cropped or whether its a bad painting problem.

    Can you try calling DrawMenuBar() after switching from Ribbon to menu interface?


    Thursday, June 13, 2019 6:35 PM
  • Thanks for your suggestion.

    I've tried calling DrawMenuBar() after switching from ribbon to menu/toolbar interface, but it doesn't work.

    Friday, June 14, 2019 8:24 AM
  • Hello,

    Thank you for posting here.

    >>We have recently implemented ribbon interface using CMFCRibbonBar

    I tried to switch between ribbon and menu/toolbar by message, but it seemed to have no change. The change in your image is not clear. Could you provide detailed steps about your method or a simple demo for us to reproduce your issue, so that we could help you easily. I think the way you implement it is very important for this issue.

    Best Regards,

    Suarez Zhou

    Monday, June 17, 2019 8:48 AM
  • Thanks Suarez.

    The code below is the function called when switching from ribbon interface to menu/toolbar interface.

    void CMainFrame::OnStyleToolbarInterface()
    	// Show the menu/toolbar and hide the ribbon
    	m_wndMainToolBar.ShowPane(TRUE, TRUE, TRUE);
    	m_wndBoundaryToolBar.ShowPane(TRUE, TRUE, TRUE);
    	m_wndGeometryToolBar.ShowPane(TRUE, TRUE, TRUE);
    	m_wndMachiningToolBar.ShowPane(TRUE, TRUE, TRUE);
    	m_wndFiveAxisToolBar.ShowPane(TRUE, TRUE, TRUE);
    	m_wndDrillingCyclesToolBar.ShowPane(TRUE, TRUE, TRUE);
    	m_wndToolpathToolBar.ShowPane(TRUE, TRUE, TRUE);
    	m_wndGraphicsToolBar.ShowPane(TRUE, TRUE, TRUE);
    	m_wndStandardViewsToolBar.ShowPane(TRUE, TRUE, TRUE);
    	m_wndAnalysisToolBar.ShowPane(TRUE, TRUE, TRUE);
    	m_wndInspectionToolBar.ShowPane(TRUE, TRUE, TRUE);
    	m_wndUVSurfacesToolBar.ShowPane(TRUE, TRUE, TRUE);
    	// Set the toolbar for the active window
    	CMDIChildWnd* pChild = MDIGetActive();
    	CDCMultiDocTemplate* pTemplate = NULL;
    	CGraphicsFrame* pGraphicsFrame = dynamic_cast<CGraphicsFrame*>(pChild);
    	if (pGraphicsFrame != NULL)
    		pTemplate = (dynamic_cast<CProTOOLMAKERApp*>(AfxGetApp()))->GraphicsDocTemplate();
    		::SetMenu(m_hWnd, pTemplate->m_hMenuShared);
    		CDatabaseFrame* pDatabaseFrame = dynamic_cast<CDatabaseFrame*>(pChild);
    		if (pDatabaseFrame != NULL)
    			pTemplate = (dynamic_cast<CProTOOLMAKERApp*>(AfxGetApp()))->DatabaseDocTemplate();
    			::SetMenu(m_hWnd, pTemplate->m_hMenuShared);
    			::SetMenu(m_hWnd, m_hMenuDefault);
    	m_wndRibbonBar.ShowPane(FALSE, FALSE, FALSE);
    	m_dwMenuBarState = AFX_MBS_VISIBLE;
    	// Forcefully redraw the frame window without changing its size and position
    	CRect rectThis;

    I cannot create a simple demo to reproduce this issue. I can only provide code snippet for investigation.

    Thanks again.

    Monday, June 17, 2019 12:01 PM
  • Hello,

    Thanks for your code.

    After testing, I found that menu bar may not be cropped. This seems to be a display error caused by the overlapping display of two menu bars. The text of the menu bar visible in this figure displays incorrectly. 

    During the testing process, it was also found that this error could not be recovered when the program restarted. After changing the values in the following figure, the program runs OK. I think this is because ribbon stores program settings in the registry, which results in the overlapping display of two menu bars. You can manually change the value of this property in the program when you want to change the interface.

    If you have any questions, please feel free too contact us.

    Best Regards,

    Suarez Zhou

    Tuesday, June 18, 2019 8:55 AM
  • Hi Suarez,

    Thanks very much for the solution.

    In your attached image, do you mean I need to set the "InVisible" property of "BasePane-59398" to "0"?

    I think "BasePane-59398" is a toolbar as BasePane is the base class of CMFCToolbar, the problem I have is the menu which is derived from CMenu. And I don't save the menu in the registry. So I don't know which property I should change.

    Thanks again.

    Tuesday, June 18, 2019 9:24 AM
  • Hello,

    My suggestion is based on my project file. You can consider modifying the value according to your own project. As for the fact that you said you did not modify the registry, I think these are all done in the CMFCRibbonBar class. The process of creating modifications is encapsulated. If you don't know which value to modify, you can refer to my method. My method is to compare the registry values when the program is running normally with those when the program runs incorectly, and then see which values have changed and consider which values may have an impact on the program. 

    Best Regards,

    Suarez Zhou

    Wednesday, June 19, 2019 8:53 AM