0
votes

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
I suggest that you post the code that has so far been unsuccessful so that people can comment directly.user1793036
There is no code involved. I have only played with the properties of the ribbon.Gumbly jr.

2 Answers

0
votes

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
votes

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.