0
votes

Ribbon buttons can have items within them. But they only, as far as I know, accept small images. I am trying to add large images to these sub items.

Does anyone know how this can be done?

Thanks,

enter image description here

Edit:

enter image description here

2

2 Answers

2
votes

Use the SetAlwaysLargeImage() member function in the menu subitems, which are usually CMFCRibbonButtons themselves:

std::auto_ptr<CMFCRibbonButton> apBtn3(new CMFCRibbonButton(ID_RIBBON_BTN_3, _T("Split Button"), 2, 2));
apBtn3->SetMenu(IDR_RIBBON_MENU_1, TRUE);
apBtn3->SetAlwaysLargeImage();
apBtn3->RemoveSubItem(0);
std::auto_ptr<CMFCRibbonButton> apSubButton(new CMFCRibbonButton(ID_RIBBON_MBTN_1, _T("Item 1"), 2, 2));    // <-- !!!
apSubButton->SetAlwaysLargeImage(); // <-- !!!
apBtn3->AddSubItem(apSubButton.release(), 0);   // <-- !!!
pPanel1->Add(apBtn3.release());

(modified code from the RibbonGadgets sample)

1
votes

This seems to be a CMFCRibbonGallery, not a CMFCRibbonButton. Code example:

pPanel1->Add(new CMFCRibbonGallery(ID_RIBBON_PBTN_1, _T("Embedded"), 0, 0, IDB_RIBBON_PALETTE_1, 64));

CMFCRibbonGallery* pBtn2 = new CMFCRibbonGallery(ID_RIBBON_PBTN_2, _T("Button"), 1, 1, IDB_RIBBON_PALETTE_1, 64);
pBtn2->SetButtonMode();
pBtn2->SetAlwaysLargeImage();
pPanel1->Add(pBtn2);

(taken from the RibbonGadgets sample)

[Edit: This is the wrong answer. Check (and upvote) my other answer. I only leave this one undeleted to honor the comments.]