There are different ways of doing it, and there may be a better way...this
is the code I use for a ListView in my common code library

            function AddIcon(FileName:string; FileIndex:word):integer;
            begin
                 try

FileIcon.Handle:=ExtractAssociatedIcon(hInstance,PChar(FileName),FileIndex);
                 except
                    FileIcon.Handle:=0;
                 end;
                 if FileIcon.Handle <> 0
                    then Result:=ImageList.AddIcon(FileIcon)
                    else Result:=-1;
            end;

FileIcon is a TIcon I have created. The function AddIcon shown above gets
the icon, adds it to a TImageList and then returns the index in the
imagelist, which can then be allocated to the appropriate property of a
listitem or treenode


> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On
> Behalf Of Laurence Bevan
> Sent: Sunday, 30 May 1999 12:50
> To: Multiple recipients of list delphi
> Subject: [DUG]: Displaying Windows Icons
>
>
> I have an application that compiles information about different file types
> in specified directories in a treeview.
>
> I want to display the appropriate icon in the treeview for each file type.
> There is a Win32 function called ExtractAssociatedIcon which apparently
> returns a handle to the associated icon, but I can't get it to work.
>
> Can anyone give me sample code of how to use this function and populate an
> imagelist?
>
> Laurence Bevan
>
>
>
> ------------------------------------------------------------------
> ---------
>     New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
>                   Website: http://www.delphi.org.nz
>

---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz

Reply via email to