Search code examples
mfcribbon

Ribbon button items with large images


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


Solution

  • 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)