i would appreciate a lot some source code in this matter.

wm_create:
....
invoke ImageList_Create,16,16,ILC_MASK + ILC_COLOR16,1,20
....
invoke SendMessage,hListView,LVM_SETIMAGELIST,LVSIL_SMALL,hImageList
.....

...
invoke ImageList_AddIcon,hImageList,hIcon
push eax
...

This call ADD the icon to the listview ?is it right?, then i call sendmessage:

...

pop eax
mov dword ptr lv_iten. iImage,eax
.....


invoke SendMessage,hListView,LVM_SETITEMTEXT,xx,xx

but ALWAYS put the same icon... if I remove the SenMessage call.. nothing occurs, the icon is put anyway... (it appears when i call imagelist_addIcon :?)

Some help appreciated.
Posted on 2004-12-23 14:45:55 by hunter
possibly you should use LVM_SETITEM instead of LVM_SETITEMTEXT. Its just a guess.
Posted on 2004-12-23 15:06:27 by japheth
it works ok now (thx) ... displays the correct icon... but SOMETIMES :? doesnt display some incons UNTIL i select one line ?update problem? ...
Posted on 2004-12-23 15:34:45 by hunter
Once you have set all your icons redraw the listview by invlidating it then updating it...

invoke InvalidateRect, , 0, 1
invoke UpdateWindow,
Posted on 2004-12-23 18:23:58 by donkey
Other question :roll:

ExtractIcon:

The return value is a handle to an icon. If the file specified was not an executable file, DLL, or icon file, the return is 1. If no icons were found in the file, the return value is NULL.


If no icon the return value is NULL, how i can set a "default" .exe/.dll icon and "default" non .exe/.dll icon? i didnt find info in a quick search on msdn...
Posted on 2004-12-24 13:59:30 by hunter
Well, if you are using it to show the icons for various exectuables and DLLs, you might be best to use SHGetFileInfo as that will get the icon that is displayed in the shell for that file, including default icons. Users will be much more familiar with them in that way.

All of this code is written in GoAsm which hanldes ordinal exports much better than MASM, in that assembler you will have to load all ordinals using GetProcAddress etc...

Define the ordinals :
Shell_GetImageLists = Shell32.DLL:71 ; offset hSysImlLarge,offset hSysImlSmall

You must first initialize the system image list for your application, this is only necessary with NT/2K/XP.

; The shell image lists must be initialized under NT/2K/XP

; This ordinal export will initialze them, it does not exist
; in any Win9x version so it must be loaded programatically
invoke GetModuleHandle,"Shell32.DLL"
invoke GetProcAddress,eax,660
or eax,eax
jz >
push TRUE
call eax
:


Then get a handle to the system image list:

; Get a handle to the system imagelists, this is called by ordinal

; Do not delete or modify these imagelists !!!!!
; The listview MUST have the LVS_SHAREIMAGELISTS style
invoke Shell_GetImageLists,offset hSysImlLarge,offset hSysImlSmall


Assign the image list to your Listview:

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

invoke SendMessage,[hListView],LVM_SETIMAGELIST,LVSIL_NORMAL,[hSysImlLarge]


To get the index of the icon in the image list for your listview use the following...

LOCAL sfi :SHFILEINFO


invoke SHGetFileInfo,OFFSET FileName,NULL,offset sfi,SIZEOF SHFILEINFO,SHGFI_SYSICONINDEX


The index is returned in sfi.iIcon
Posted on 2004-12-24 14:30:17 by donkey
You can check out WinExplorer, I wrote it to test just this sort of thing, it is available here:

WinExplorer.zip

Feel free to use modify or otherwise pilfer anything you want from the app, there is no liscense except that you can do anything you want with it. GoAsm source is included.
Posted on 2004-12-24 14:44:22 by donkey