Jump to content

Error when changing icon font color "UniNativeImageList" in runtime


Luciano França

Recommended Posts

I need to change the color of Icons at runtime according to the type of Themes that the user chooses

I believe it is a bug because it gives an AccessViolation error

procedure TMainForm.UniButton1Click(Sender: TObject);
Var I : Integer;
begin
  for I := 0 to UniNativeImageList1.Count - 1 do
   UniNativeImageList1.Images[I].FontColor := clwhite;
end;
 

 

Link to comment
Share on other sites

On 9/1/2023 at 11:50 AM, Luciano França said:

I need to change the color of Icons at runtime according to the type of Themes that the user chooses

I believe it is a bug because it gives an AccessViolation error

procedure TMainForm.UniButton1Click(Sender: TObject);
Var I : Integer;
begin
  for I := 0 to UniNativeImageList1.Count - 1 do
   UniNativeImageList1.Images[I].FontColor := clwhite;
end;
 

 

 

I believe it is a bug in the "UniNativeImageList" component because it cannot access the list in "UniNativeImageList.Images"

In this way, my solution for those who need it is

Procedure TForm_MenuPrincipal.P_ColorSkinWeb;
Var I: Integer;
Var ColorIcons: TColor;
Var ListIcons: TStrings;
Var aFontFamily: TUniIconFontFamily;
Begin
 if Not AnsiSameText(PathSkinName, 'uni_ubuntu') then
  Exit;

 ListIcons := TStringList.Create;
 Try

  for I := 0 To WEB_IconFontsListMenu.Count - 1 do
   ListIcons.AddObject(WEB_IconFontsListMenu.GetIconCls(I, aFontFamily, ColorIcons), TObject(aFontFamily));

  if AnsiSameText(PathSkinName, 'uni_ubuntu') then
   ColorIcons := clWhite
  Else
   ColorIcons := clBlack;

  WEB_IconFontsListMenu.Clear;
  for I := 0 to ListIcons.Count - 1 do
   if Trim(ListIcons.Strings[I]) <> EmptyStr Then
    WEB_IconFontsListMenu.AddIconCls(ListIcons.Strings[I], TUniIconFontFamily(ListIcons.Objects[I]), ColorIcons);

 Finally
  FreeAndNil(ListIcons);
 End;

End;

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...