One other thing: the FileIndex mentioned as below.
Normally I use 0 for a file, but if you are using a shortcut it can be a
different value and filename, which can be extracted from the properties of
the shortcut.
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On
> Behalf Of Patrick Dunford
> Sent: Sunday, 30 May 1999 13:45
> To: Multiple recipients of list delphi
> Subject: RE: [DUG]: Displaying Windows Icons
>
>
> 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),F
> ileIndex);
> 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
>
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz