Re: Using Win32Lib's geFileInfo to show system icon

new topic     » goto parent     » topic index » view thread      » older message » newer message

Using the code you are using could cause problems, particularly if the code is
called many times and with Win98.

But there is an alternative you might consider. Win32Lib does maintain it's own
imagelist but you do not have to use it. You may be able to use the system
imagelist whose handle can be obtained with the following code:

file_info=getFileInfo("*.txt",#80,
     or_all({SHGFI_SYSICONINDEX+SHGFI_USEFILEATTRIBUTES+SHGFI_SMALLICON})

file_info[7] will contain the handle to the system imagelist.

You can then do:

void=sendMessage(MainTV,TVM_SETIMAGELIST,TVSIL_NORMAL,file_info[7])

to use this image list in the Treeview control.

Use the icon index returned by getFileInfo() directly in addTVItem()

But there are a number of things to remember when doing this. The system
imagelist is owned and managed by the system and should never be destroyed or
directly modified by the application. Doing this on Win98 will corrupt a vital
system resource and require a reboot. getFileinfo() will add any required images.
On NT platforms you will be working with a private copy of the real system
imagelist and no problems should result. But any direct modification of this list
is unsupported and discouraged by Microsoft.

This means that you can use only images in the system imagelist, you can not add
your own. If this is acceptable to your application then this would be a viable
alternative. There should be no concerns over resource usage and performance will
be much better. Adding an icon to an imagelist can be a time consuming operation.

I learned this from a lot of browsing MSDN & elsewhere and trial and error -
mostly error.

Larry Miller

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu