@@ -230,8 +230,6 @@ TUIRibbon = class(TWinControl, IUIApplication)
230230 function GetBackgroundColor : TColor;
231231 function GetHighlightColor : TColor;
232232 function GetTextColor : TColor;
233- // / OnChange event handler for fImageChangeLink. Reacts to image changes and refreshes all commands' icons
234- procedure ImageListChange (Sender: TObject);
235233 procedure SetBackgroundColor (const Value : TColor);
236234 procedure SetHighlightColor (const Value : TColor);
237235 procedure SetTextColor (const Value : TColor);
@@ -450,6 +448,9 @@ TUIRibbon = class(TWinControl, IUIApplication)
450448 // / True if the ribbon has been loaded from then resource and has been initialized; False otherwise.
451449 property IsLoaded: Boolean read fLoaded;
452450
451+ // / OnChange event handler for fImageChangeLink. Reacts to image changes and refreshes all commands' icons
452+ procedure ImageListChange (Sender: TObject);
453+
453454 { Whether the UI Ribbon Framework is available on the system.
454455 Returns False when the application is not running on Windows 7 or
455456 Windows Vista with the Platform update. In that case, all ribbon
@@ -1044,6 +1045,7 @@ procedure TUIRibbon.ImageListChange(Sender: TObject);
10441045var
10451046 lCommand: TUICommand;
10461047 lImageIndex: Integer;
1048+ lActionManager: TActionManager;
10471049begin
10481050 if not (roAssignImagesFromActionManager in Self.Options) then
10491051 Exit; // ActionManager's images are not actually used -> Nothing todo
@@ -1052,21 +1054,17 @@ procedure TUIRibbon.ImageListChange(Sender: TObject);
10521054 for lCommand in Self do
10531055 begin
10541056 // Check if this command has an action. If yes, use the action's image index.
1055- if Assigned(lCommand.ActionLink) and Assigned(lCommand.ActionLink.Action) then
1057+ if Assigned(lCommand.ActionLink) and Assigned(lCommand.ActionLink.Action) and Assigned(TCustomAction(lCommand.ActionLink.Action).ActionList) then
10561058 begin
1057- // Check if this commands action manager is the one we registered for changes. Skip otherwise.
1058- if (lCommand.ActionLink.Action is TContainedAction) and (TContainedAction(lCommand.ActionLink.Action).ActionList <> Self.ActionManager) then
1059- continue;
1060-
1059+ lActionManager := TCustomAction(lCommand.ActionLink.Action).ActionList as TActionManager;
10611060 lImageIndex := TCustomAction(lCommand.ActionLink.Action).ImageIndex;
1062- end
1063- else
1064- continue;
10651061
1066- // Create a new SmallImage and LargeImage
1067- lCommand.SmallImage := TUIImage.Create(Self.ActionManager.Images, lImageIndex);
1068- if Assigned((Self.ActionManager as TActionManager).LargeImages) then
1069- lCommand.LargeImage := TUIImage.Create((Self.ActionManager as TActionManager).LargeImages, lImageIndex);
1062+ // Check if this action's imagelist is the one we registered for changes. Skip otherwise. Check if small or large image should be adjsuted
1063+ if (lActionManager.Images = Sender) then
1064+ lCommand.SmallImage := TUIImage.Create(Sender as TCustomImageList, lImageIndex)
1065+ else if ((lActionManager.LargeImages = Sender)) then
1066+ lCommand.LargeImage := TUIImage.Create(Sender as TCustomImageList, lImageIndex)
1067+ end ;
10701068 end ;
10711069end ;
10721070
0 commit comments