Implementing a ribbon using C++ in native app

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

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


Tagged: ,

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: