none
How to add icons to commands in context menu in ribbon interface? RRS feed

  • Question

  • I have a ribbon created with CMFCRibbonBar, each button on the ribbon has a command ID and an image index to set an icon on the button. The icon can be displayed correctly on each button on the ribbon.

    I also would like to display icons for the commands in the context menu, which has same command IDs on the ribbon. My question is how to associate each command with each icon so that the icon for each command can also be displayed in the context menu?

    Thanks in advance.



    • Edited by Yan Yang Monday, September 16, 2019 10:58 AM
    Monday, September 16, 2019 10:57 AM

All replies

  • Hello,

    Thank you for posting here.

    >>My question is how to associate each command with each icon so that the icon for each command can also be displayed in the context menu?

    I find the default ribbon mfc application has icons in context menu.

    So I go to OnRbuttonUp() of View class and find it show context menu by ShowPopupMenu().

    But the IDR_POPUP_EDIT has no icons.

    In fact, the icons are belong to toolbar. They need the same ID to ensure that the icon will be displayed.

    To test that they connect with each other by ID. I add a menu option and give it the same ID as cut, and the result is that it displays the icon of cut.

    Finally, we link the Bitmap resources with the toolbar by CMFCToolBar::AddToolBarForImageCollection(ToolBarID,BitmapID). Then the context menu will be display with icons.


    Best Regards,

    Suarez Zhou




    Tuesday, September 17, 2019 2:39 AM
  • Hello,

    Do you resolve the issue? If you resolve the issue, could you please mark the helpful as answer. it will be beneficial to other community.

    Best Regards,

    Suarez Zhou

    Thursday, September 19, 2019 1:48 AM