Cannot set icons for buttons in the ribbon of MFC office style application

1.4k views Asked by At

The only icons I was able to set for buttons in the ribbon of my MFC Office style application are the ones made available through the image index combo boxes in the button properties, all attempts to add custom images as icons failed.

Can someone please walk me through the process of setting icons for MFC ribbon buttons?

2

There are 2 answers

0
thomiel On

Instead of using an index when creating the button like this

CMFCRibbonButton *btnMyButton = 
    new CMFCRibbonButton (ID_APP_ABOUT, _T("About"), 13, 13);

you also can do it this way:

CMFCToolBarImages m_myOtherPanelImages;
...
CMFCRibbonButton *btnMyButton = new CMFCRibbonButton (ID_APP_ABOUT, 
    _T("About"), m_myOtherPanelImages.ExtractIcon(0));
0
sergiol On

In my CMFCRibbonBar derived clas, I use something like:

CMFCToolBarImages* pImageList;

pImageList= &GetCategory(0)->GetLargeImages();
pImageList->AddIcon(theApp.LoadIcon(IDI_SOME_ICON), true);

// ... and so on for every categorry and button, assuming that you have set the LARGE image indexes correctly for each button.

and it works.