Delphi 12 - Child items of a Ribbon are turning black after minimizing

114 Views Asked by At

I was using Delphi 10.3, but after migrating the project to Delphi 12, a bug is occurring with the children of the main Ribbon in the system.

When opened, the children appear normally: enter image description here

However, when minimizing and maximizing the screen again, the children are turning black:

enter image description here

I've tried changing the style, recreating the entire form, altering various options, attempted to use Repaint or Invalidate, and still, the issue persists.

Note: The ribbon is being created dynamically; I'm not sure if that could be interfering.

I've attempted to change the style, recreate the entire form, alter various options, tried using Repaint or Invalidate, and yet the problem persists.

Edit: I noticed that this only happens when I use the 'UseCustomFrame' option as true.

Edit 2: I am creating the child components of the Ribbon like this:

procedure TFrmPrincipal.CriarComponentesRibbon;
var
  i, ComponentCountAux  : integer;
  Nome                  : String;
  mComp                 : TComponent;
  mGroup                : TRibbonGroup;
  ActionBarItem1        : TActionBarItem;
  ActionClientItem1     : TActionClientItem;
begin
  ComponentCountAux := ComponentCount-1;
  for I := 0 to ComponentCountAux do
  begin
    if (Components[i]is TMenuItem) then
    begin
      Nome:=TMenuItem(Components[i]).Name;
      if (TMenuItem(Components[i]).Visible) and (copy(TMenuItem(Components[i]).Name,1,1)='A') then
      begin
        Nome:=TMenuItem(Components[i]).Name;

        if ((Length(Copy(Nome,2,5))=3) or ((Length(Copy(Nome,2,5))=4) and (TMenuItem(Components[i]).Action=nil))) or
        ((Length(Copy(Nome,2,5))=2) and (Copy(Nome,2,1)='4'))  then
        begin
          if ((Length(Copy(Nome,2,5))=3) or (Length(Copy(Nome,2,5))=4)) then
          begin
            mComp:=FindComponent('R'+copy(Nome,2,2));
          end
          else if ((Length(Copy(Nome,2,5))=2) or (Copy(Nome,2,1)='4')) then
          begin
            mComp:=FindComponent('R'+copy(Nome,2,1));
          end;
          if mComp is TRibbonPage then
          begin
            mGroup:=TRibbonGroup.Create(Self);
            mGroup.Parent:=TRibbonPage(mComp);
            mGroup.Name:='R'+copy(TMenuItem(Components[i]).Name,2,5);
            mGroup.Caption:=copy(TMenuItem(Components[i]).Caption,(pos('-',TMenuItem(Components[i]).Caption)+1),Length(TMenuItem(Components[i]).Caption)-2);
            mGroup.Font.Color:=clBlack;
            mGroup.Color:=clBlack;
            ActionBarItem1:=ActionManager.ActionBars.Add;
            ActionBarItem1.ActionBar:=mGroup;
          end;
        end;
        if (((Length(Copy(Nome,2,5))=4) or (Length(Copy(Nome,2,5))=5) or (Length(Copy(Nome,2,5))=3)) and (TMenuItem(Components[i]).Action<>nil)) or
        ((Length(Copy(Nome,2,5))=2) and (Copy(Nome,2,1)='4') and (TMenuItem(Components[i]).Action<>nil))  then
        begin
          ActionClientItem1:=ActionBarItem1.Items.Add;
          ActionClientItem1.Action:=TContainedAction(TMenuItem(Components[i]).Action);
          ActionClientItem1.Caption:=copy(TMenuItem(Components[i]).Caption,(pos('-',TMenuItem(Components[i]).Caption)+1),Length(TMenuItem(Components[i]).Caption)-2);

          if ((Length(Copy(Nome,2,5))=3) or ((Length(Copy(Nome,2,5))=2) and (Copy(Nome,2,1)='4') and (TMenuItem(Components[i]).Action<>nil))
            or (TMenuItem(Components[i]).Default=True)) then
            (ActionClientItem1.CommandProperties as TButtonProperties).buttonSize:=bsLarge
          else
            (ActionClientItem1.CommandProperties as TButtonProperties).buttonSize:=bsSmall;
          ActionClientItem1.ImageIndex:=TMenuItem(Components[i]).ImageIndex;
        end;
      end;
    end;
  end;
end;
0

There are 0 best solutions below