0

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

ali
  • 529
  • 4
  • 26

2 Answers2

2

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)

thomiel
  • 2,467
  • 22
  • 37
  • Great! The same can be achieved through the ribbon xml element property. – ali Mar 03 '14 at 14:24
  • It can be added along the other large icons but I couldn't manage to make the check box itself as large even if the "Always Large" attribute is set to "True". Have a look at the picture in Edit part of the question. – ali Mar 12 '14 at 17:40
  • I know. Whenever a large image is set in the subitem, the checkbox is being hidden. – thomiel Mar 13 '14 at 13:41
  • I started a new question [here](http://stackoverflow.com/questions/22302164/ribbon-button-items-with-large-images-and-checkboxes). – thomiel Mar 13 '14 at 13:47
1

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.]

thomiel
  • 2,467
  • 22
  • 37
  • Thanks thomiel, as far as I know, gallery items are images which can be large ones. But you can't assign caption to each item like the above pic unless the text is in the bitmap. Is that right? Whereas with CMFCRibbonButton, subitems can get caption along the image. Only the image has to be small. So I wondered if there is a way to make CMFCRibbonButton subitems to get large image as well. – ali Mar 03 '14 at 10:43
  • You are probably right. So give me another try... :) I do use VS2008 with the feature pack. VS2010 has a ribbon designer, as far as I know, but I don't know it it is a good one. – thomiel Mar 03 '14 at 11:52