Originally posted by: Christian Oppermann
Hi!
I tried to display icons for files that does not really exist on the harddisk. I need this for a file cataloging utility.
E.G. if I archived the file text.txt I want the TXT-Icon to be displayed, but SHGetFileInfo only works with existing files. Any ideas to solve the problem?
BTW.: Until now I extracted the File type info from the Windows registry, but that takes too much time.
ReplyOriginally posted by: Matthew Vincent
I'm on NT and my image list is small. How do I iterate through the various documents to get the full system image list?
ReplyOriginally posted by: C4
Well, I am not sure on going about doing this but I want to use the imagelist_draw function to creat a BMP instead of using an ICON... any sugeestions?
Thanks
ReplyOriginally posted by: Nathan Moinvaziri
Last updated on 09/18/1999
- Added : New Source Code for Getting File Type Icons
Download code at uncompressor.cjb.net/c/systemil.zip
----
LPCSTR lpName = "c:\\windows";
CSysImg.SetStyle(SHGFI_SMALLICON | SHGFI_SYSICONINDEX);
m_List.SetImageList(CSysImg, LVSIL_SMALL);
--------
To extract an icon from the system imagelist use:
HICON hIcon = CSysImg.ExtractIcon(CSysImg.GetIndex(lpName));
To get the icon of a specific file type use:
HICON hIcon = CSysImg.GetTypeIcon(".exe");
To get the index of a file type's icon in the system imagelist use:
int iTypeIdx = CSysImg.GetTypeIndex(".exe");
To get a file's icon use:
HICON hIcon = CSysImg.GetFileIcon("c:\\autoexec.bat");
To get a file icon's index in the system imagelist use:
int iFileIdx = CSysImg.GetFileIndex("c:\\autoexec.bat");
When I firsted used the code by Matt Esterly I had problems using it.
Most of the time it wouldn't give my system back it's icons, so I would have to
restart. This is probably due to the problem that he attached the system imagelist
to a HIMAGELIST structure. Then attached it to a CImageList class structure.
But when you finish with your program, and detach the HIMAGELIST structure from
the CImageList class structure, the HIMAGELIST structure is still attached to the system
imagelist. I think this was the problem. I'am using Windows 98, so this could
be a Windows '98 bug or something. The code below is an alternative example
using the same class as Matt Esterly but changing it so it would work on my
system for me.
EX:
----
CSystemImageList CSysImg;
m_List.InsertItem(0, lpName, CSysImg.GetIndex(lpName));
How To
---------
Originally posted by:
Reply
Originally posted by: sheilendra parekh
Hi All,
hi tried to use this api based on the example given but have not had much joy.
Essentially What I have is and explorer interface and when I add items to the tree I want to use the actual application icon on the tree.
EG if I add Word to the tree then I want to see the Word Icon.
Unfortunately it doesn't work.
I pass the location of Word as the first param to SHGetFileInfo(); and all the structures appear to be correctly populated.
Any ideas??
I'm on nt4 with vc 5.0
Thanks for your help!!
Originally posted by: Bob Pittenger
When I use this code on Windows 98, a peculiar thing happens. After a call SetImageList with the system image list, if I start Windows Explorer, the tree control in Windows Explorer has the system button face color as a background color for the images in the tree. I suspect this is a problem with Windows 98 rather than the code because the code is simple enough and Windows 98 has all sorts of image related bugs (at least on my machine). Has anyone else seen this?
ReplyOriginally posted by: Bob Pittenger
Apparently, you can only attach the system image list to a CImageList object once. It is better to have the m_ImageList members as static members. Then attach the system images to the CImageList object on program startup and detach on program shutdown.
ReplyOriginally posted by: Roger J. Lee
Is there a way to force NT4 to act like 95/98 (give me the full imagelist, instead of doing it one by one, upon request). If there is no way to do that, can NT4 at least give me the overlay icon handle?
Reply