I've got a menu attached to a split ribbon button like this (VS2008, Feature Pack):
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());
I want to put checkboxes in front of each menu item and have provided SetCheck()
calls in the CN_UPDATE_COMMAND_UI
handler but checkboxes will only show up, if I disable the large icons.
Is there any way to use checkboxes along with large icons in CMFCRibbonButton
menus? If not, what would be the best possible workaround?
I found a usable workaround to check large icons by alpha-blending a green circle with a checkmark in it over the icon -- the same solution Windows uses to mark the default audio device or printer in the control panel:
This is my CMFCRibbonButtonEx class declaration:
Here are the class function definitions:
IDB_BIG_ICON_CHECKMARK is a 32bit bmp with alpha channel: Download here
Sadly, in OnCmdMsg only a fake
CMFCRibbonButton
created by the ribbon framework is being maintained, soSetCheck()
doesn't have any effect on anIsChecked()
call inDrawImage()
. You just have to find the realCMFCRibbonButtonEx
in the subitems of the menu like this:Should anyone know how to connect the fake
CMFCRibbonButton
(orCMFCRibbonBaseElement
) maintained byCCmdUI
to the originally createdCMFCRibbonButtonEx
, please leave me a comment.Is the below picture what you're looking for? If yes, this can be achieved by editing the ribbon xml file.