ListView file icons transparency

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #34463
    emailaya
    Participant

    hi

    please see attached.

    im using the following code to get the file icon according to its extention, put it in an image list and assign the relevant imageindex

    function GetFileIcon(const FileName:string; var ImgListTarget:TImageList):Integer;

    var FileInfo: SHFileInfoW;

    Name :array[0..255] of Char;

    Icon1 :TIcon;

    p : Word;

    begin

    Result := -1;

    try

    if FileExists(FileName) then

    begin

    Icon1 :=TIcon.Create;

    try

    Result:=-1;

    Icon1.Handle:= ExtractAssociatedIcon(HINSTANCE,StrPCopy(Name,FileName),p);

    if Icon1.Handle<>0 then

    Result:=ImgListTarget.AddIcon(Icon1);

    finally

    icon1.free;

    end;

    end

    else

    begin

    SHGetFileInfo(PWideChar('x' + ExtractFileExt(FileName)), 0, FileInfo, SizeOf(FileInfo), SHGFI_ICON + SHGFI_SMALLICON + SHGFI_USEFILEATTRIBUTES + SHGFI_TYPENAME);

    try

    Result := ImageList_AddIcon(ImgListTarget.Handle,FileInfo.hIcon);

    except

    Result := -1;

    end;

    end;

    except

    ;

    end;

    end;

    any idea why the txt icon is ok while the php icon has a black background?

    i changed the imagelist drawingstyle to dsTransparent but it didnt change anything

    please advice

    thanks

    #45326
    Support
    Keymaster

    Hello

    Try TsAlphaImageList component 🙂

    #45330
    emailaya
    Participant

    I will try but I hope it wont mean I will need to replace all my imagelist components

    thanks

    #45353
    emailaya
    Participant

    I changed only the relevant imagelists to alpha ones and it seems to do the trick

    any reason to change ALL my imagelist? I mean is there a real advantage to the alpha version?

    thanks

    #45360
    Support
    Keymaster

    No need to change all ImageLists, but AlphaImageList is better and have some useful features )

    #45365
    emailaya
    Participant
    'Support' wrote:

    No need to change all ImageLists, but AlphaImageList is better and have some useful features )

    You wrote: “better and have some useful features”

    better in what way?

    useful features like what?

    thanks

    #45370
    Support
    Keymaster

    – Png files are stored in Exe as Png

    – Resizing of ImageList is possible without reloading of pictures

    – You can just drag images from explorer to editor window in design-time

    – Components in the package are optimized for using with AlphaImageList

    – Support of reflected glyphs in buttons

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.