In my modeler, I have a Ribbon with pictures inside.
To build it, you need some code.
CRibbonListButton *pListBtnInfra = new CRibbonListButton(ID_DESIGN_SHAPESINFRA, _T("Infrastructure\nti"), 20, -1, FALSE); pListBtnInfra->AddGroup(_T("Built-In"), IDB_SHAPES_INFRA, 64, m_arInfraShapes); pListBtnInfra->SetIconsInRow(4); pListBtnInfra->EnableMenuResize(); pPanelDesign->Add(pListBtnInfra);
The class CRibbonListButton provides a simple way to load a full bitmap and display each part of it in a cell. IBD_SHAPES_INFRA is defined in the resource file as a PNG in res\ShapesInfra.png
To handle the click on the ribbon in your view, you just have to retrieve the ID of the clicked bitmap using CMFCRibbonGallery::GetLastSelectedItem().
void CModeler1View::OnModelingInfrastructure() { // TODO: Add your command handler code here GetManager()->m_type = ElementType::type_shapes_infrastructure; int shapeId = CMFCRibbonGallery::GetLastSelectedItem(ID_DESIGN_SHAPESINFRA); GetManager()->m_shapeType = CShapeType::ToShapeType(OffsetShapes_Infrastructure + shapeId); //CString str; //str.Format("shapeId=%d m_shapeType=%d", shapeId, GetManager()->m_shapeType); //AfxMessageBox(str); }
Leave a Reply