Sounds like you are having problems there Patrick. Not a lot of help, but have you 
tried using the system image list to how the icons in the list view?

It works well, and you do not have to populate the image list your self.

{-----------------------------------------------------------------------------}
{ TSystemImageList v1.10                                                      }
{-----------------------------------------------------------------------------}
{ A component to extend the TImageList so that it gives access to the system  }
{ image list.                                                                 }
{ Copyright 1998, Brad Stowers.  All Rights Reserved.                         }
{ This component can be freely used and distributed in commercial and private }
{ environments, provied this notice is not modified in any way and there is   }
{ no charge for it other than nomial handling fees.  Contact me directly for  }
{ modifications to this agreement.                                            }
{-----------------------------------------------------------------------------}
{ Feel free to contact me if you have any questions, comments or suggestions  }
{ at [EMAIL PROTECTED]                                                      }
{ The lateset version will always be available on the web at:                 }
{   http://www.pobox.com/~bstowers/delphi/                                    }
{ See SystemImageList.txt for notes, known issues, and revision history.      }
{-----------------------------------------------------------------------------}
{ Date last modified:  December 22, 1998                                      }
{-----------------------------------------------------------------------------}

Christopher Crowe (Software Developer)
Microsoft MVP, MCP

Adrock Software
Byte Computer & Software LTD
P.O Box 13-155 
Christchurch
New Zealand
Phone/Fax (NZ) 03-3651-112


> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On
> Behalf Of Patrick Dunford
> Sent: Sunday, 25 April 1999 19:17
> To: Multiple recipients of list delphi
> Subject: [DUG]: Icons from files
> 
> 
> I have a common code routine that displays in a listview, a list of files
> together with their icons.
> 
> It keeps crashing with various error messages when displaying files from a
> certain directory on my disk. The part of the code which produces 
> the crash
> is the part which gets the icon from the file.
> 
>             function AddIcon(FileName:string; FileIndex:word):integer;
>             begin
> 
> FileIcon.Handle:=ExtractAssociatedIcon(hInstance,PChar(FileName),F
> ileIndex);
>                  if FileIcon.Handle <> 0
>                     then Result:=ImageList.AddIcon(FileIcon)
>                     else Result:=-1;
>             end;
> 
> This function adds the icon if it exists to the imagelist and then returns
> the index into the imagelist, this is then assigned by the calling routine
> to the listview item.
> 
> If the call to ExtractAssociatedIcon is commented out then the 
> program runs
> reliably, if it is left in then even if the rest is commented out, the
> errors produced vary from Invalid pointer operation to Stack overflow,
> Access violation and Invalid page fault.
> 
> D3.02, Win95OSR2, IE5
> ============================================
> Patrick Dunford, Christchurch, NZ
> http://patrick.dunford.com/
> 
> ------------------------------------------------------------------
> ---------
>     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