Assigning Image from PNG or JPG file as Ribbon control image

Add-in Express™ Support Service
That's what is more important than anything else

Assigning Image from PNG or JPG file as Ribbon control image
How to assign an image file (eg Company Logo) as image for Ribbon controls (tadxRibbonMenu/ tadxRibbonButton) 
Grafe Libao




Posts: 1
Joined: 2021-10-12
We have a COM Add-In for Excel and currently using TadxRibbonTab

When using XLA, we normally do this using
getImage='GetImage'
and assign the image using IPictureDisp.

Does Add-in Express support the same method? How? Do you have a sample?

Edit: I know how to use Glyph. What we need however it to assign the image dynamically, as the image file names will depend on some logic.


Thanks
Posted 16 Oct, 2021 15:18:01 Top
Andrei Smolin


Add-in Express team


Posts: 18224
Joined: 2006-05-11
Hello Grafe,

Simply setting the Glyph property at the run time should work. This is what Add-in Express does when you do this:


procedure TadxRibbonCustomControl.SetGlyph(Value: TBitmap);
begin
  FGlyph.Assign(Value);
  Invalidate;
  if Self is TadxRibbonItem then begin
    if TAccessCollection(Self.Collection).GetOwner is TadxRibbonDropDown then
      TadxRibbonDropDown(TAccessCollection(Self.Collection).GetOwner).Invalidate;
  end;
end;


The Invalidate call invalidates the corresponding control and this makes Office invoke the corresponding callbacks thus refreshing the image.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 18 Oct, 2021 03:44:47 Top