Graphics->DrawRectangle(&colorPen, rect.left, rect.top, rect.Width(), rect.Height()) When the image is not selected, there is a rectangle drawed with the primitive DrawRectangle and DrawLine: Then, you click in the Properties View the Image button. In my application the draw picture is used first by clicking Picture in the upper left side of the ribbon. The DrawImage member function of Graphics just makes the job. Graphics->DrawImage(&image, rect.left, rect.top, image.GetWidth(), image.GetHeight()) If( m_type = ElementType::type_shapes_infrastructure ) Image image(CStringW(imageFilePath.c_str())) Graphics * graphics = ctxt.GetGraphics()
#Pug language p full
Just declare an Image object and fill a CStringW with the full path of your picture. Then, you have all the API from GDI+ available with the graphics object. I store the graphics object in a context class to have a single point of definition.
On my side, the Graphics object is acquired with the View::OnDraw with : First you must acquire a Graphics object from GDI+. How can you do that operation using Win32 SDK? In my application Modeler1, I can display pictures. M_arInfraShapes.Add(_T("Virtualization Server")) M_arInfraShapes.Add(_T("Virtual Database Server")) M_arInfraShapes.Add(_T("Virtual Web Server")) M_arInfraShapes.Add(_T("Virtual Server")) M_arInfraShapes.Add(_T("Database Server")) To display a text under each bitmap,we initialize a StringArray previously in the class: PListBtnInfra->AddGroup(_T("Built-In"), IDB_SHAPES_INFRA, 64, m_arInfraShapes)
![pug language p pug language p](https://image.shutterstock.com/image-vector/letter-p-lowercase-cute-children-600w-1506885758.jpg)
The code to create the ribbon element is simple:ĬRibbonListButton *pListBtnInfra = new CRibbonListButton(ID_DESIGN_SHAPESINFRA, _T("Infrastructurenti"), 20, -1, FALSE) In my case, I have a large image named ShapesInfra.png defined in the resource as IDB_SHAPES_INFRA. To make a Ribbon button with various shapes (elements), you have to define a bimap.