Jump to content

Recommended Posts

Posted

unit Convert To 32 Bitmap UniImage List

Remove the round black icon

unit ConvertTo32BitImageList;

interface

uses SysUtils, Graphics, Classes, Controls, ImgList, CommCtrl, Consts,
  uniImageList;

procedure AddIconToUniImageList32bit(CountIcon: Integer; aUniImageList: TUniImageList);

implementation

procedure P_ConvertTo32BitImageList(const ImageList: TImageList);
const
  Mask: array [Boolean] of Longint = (0, ILC_MASK);
var
  TemporyImageList: TImageList;
begin
  if Assigned(ImageList) then
  begin
    TemporyImageList := TImageList.Create(nil);
    try
      TemporyImageList.Assign(ImageList);
      with ImageList do
      begin
        ImageList.Handle := ImageList_Create(Width, Height, ILC_COLOR32 or
          Mask[Masked], 0, AllocBy);
        if not ImageList.HandleAllocated then
        begin
          raise EInvalidOperation.Create(SInvalidImageList);
        end;
      end;
      ImageList.AddImages(TemporyImageList);
    finally
      TemporyImageList.Free;
    end;
  end;
end;

procedure AddIconToUniImageList32bit(CountIcon: Integer; aUniImageList: TUniImageList);
var
  ICO: Ticon;
  i: Integer;
  ImgList: TImageList;
begin
  ImgList:=TImageList.Create(nil);
  try
    ImgList.Clear;
    P_ConvertTo32BitImageList(ImgList);

    for i := 0 to CountIcon do
    begin
      ICO := Ticon.Create;
      try
        if FileExists(ExtractFilePath(ParamStr(0))+'pic\' + IntToStr(i) + '.ico') then
          ICO.LoadFromFile(ExtractFilePath(ParamStr(0))+'pic\'  + IntToStr(i) + '.ico')
        else
          exit;
        ImgList.AddIcon(ICO);
      finally
        ICO.Free;
      end;
    end;
    aUniImageList.Assign(ImgList);
  finally
    ImgList.Free;
  end;
end;

end.

uses:

  AddIconToUniImageList32bit(3, UniImageList1);
  ShowMessage(IntToStr(UniImageList1.Count));
  for i := 0 to 3 do
  begin
    UniTreeView1.items[i].ImageIndex := -1; // add this
    UniTreeView1.items[i].ImageIndex := UniImageList1.Count - UniImageList1.Count+i;
  end;
  • Upvote 1

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...