I have a listview that displays a list of files. How would I load the icons for these files? Say if it was an mp3 then I need to find out what icon the system uses for mp3s and load it.
Posted on 2004-01-14 02:28:12 by ENF
Hi ENF,

Create an image list. Load the icons into the image list then use their index # in the iImage parameter of LV_ITEM:

invoke ImageList_Create,16,16,ILC_MASK + ILC_COLOR24,1,10

mov [hIml],eax
invoke LoadIcon,[hInstance],10000
push eax
invoke ImageList_AddIcon,[hIml],eax
pop eax
invoke DestroyIcon,eax
invoke LoadIcon,[hInstance],10001
push eax
invoke ImageList_AddIcon,[hIml],eax
pop eax
invoke DestroyIcon,eax

invoke SendMessage, [hListView], LVM_SETIMAGELIST, LVSIL_SMALL, [hIml]


Note that once the icon is added to the image list it is no longer needed and can be destroyed.
Posted on 2004-01-14 08:37:52 by donkey
thank you donkey, but I still don't know how to find the icons to load. I need to know wich icon the shell uses to display a file of a particular type, and where that icon can be found. I know I could have an icon for each file type as a resource and use that but I wonder if there is an api to use the same icon that explorer would use?
Posted on 2004-01-14 09:36:57 by ENF
There is a function for that ExtractAssociatedIcon, use that instead of LoadIcon, providing the path to the file or executable.
Posted on 2004-01-14 10:11:27 by donkey