XML XML Ribbon: A collapsed group that displays only the default image.

We have a Word add-in implemented in C ++ as a COM add-in. Our tape group is loaded using the GetCustomUI callback. When Word 2010 displays our ribbon group in a minimized layout, only the default icon is displayed.

<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" onLoad="OnLoad"> <ribbon> <tabs> <tab idMso="TabReviewWord"> <group id="MyGroup" label="My AddIn" getImage="GetGroupImage" insertAfterMso="GroupProofing" > ....... STDMETHODIMP CWordPlugIn::GetGroupImage(IDispatch* pRibbon, IPictureDisp** ppdispImage) { return GetImage(GetGroupIcon(16), ppdispImage); }; HRESULT CWordPlugIn::GetImage(HICON hIcon, IPictureDisp** ppdispImage) { PICTDESC pd; memset(&pd, 0, sizeof(pd)); pd.cbSizeofstruct = sizeof(pd); pd.picType = PICTYPE_ICON; pd.icon.hicon = hIcon; if ( pd.icon.hicon == NULL ) { return E_INVALIDARG; }; HRESULT hRes = OleCreatePictureIndirect(&pd, IID_IPictureDisp, FALSE, (LPVOID *) ppdispImage); if ( hRes != S_OK ) { //write log }; return hRes; }; 

When I do not define a getImage callback for a group, the collapsed group shows the default Microsoft icon. When I define the getImage callback, my icon is not displayed, just an empty image. The same callback works fine for button icons. How to identify the group softkey that is displayed for collapsed groups? I tried both 16 and 32 pixel icons.

+4
source share
1 answer

Fixed: When I return an icon containing both images with 16 and 32 (and 48 pixels), it works as expected.

For some reason, we used different icon resources (separate files containing 16 or 32 pixel icons) for small and large ribbon buttons. Instead, use icons containing all sizes in a single icon file. Bonus: when the icon contains a 48-pixel image, the ribbon buttons are correctly colored for scaled system fonts.

+1
source

Source: https://habr.com/ru/post/1442941/


All Articles