//I added mycomputer and desktop icons because i dont know how to get them:>
CString strIconPath = sysdir;
strIconPath += "\\Shell32.dll";
HICON* phiconLarge = new HICON;
HICON* phiconSmall = new HICON;
ExtractIconEx(strIconPath,34, phiconLarge, phiconSmall, 1); //load desktop icon on index 4
ExtractIconEx(strIconPath,15, &phiconLarge, &phiconSmall, 1); //load mycomputer icon on index 5
After this change, you can call GetIcons() with:
"somedir\\", "c:\\", "f:" etc. to retrieve folder or
drive icons. Network folders will work also with "\\\\tel"
and drives mapped to network directories.
One could also use some additional flag, but I think
this is more simple. In any way, the file attribute
is the trick.
Good job on the system image list code. One question, how can I display small icons in the list control? The tree control displays them correctly, but I would like to see them in the list control as well.
When I set the list control view to "Small Icon", the icons are not displayed, only the file names are visible.
To get folder and drive icons, change CSystemImageList::GetIcon() so that you include
FILE_ATTRIBUTE_DIRECTORY along with FILE_ATTRIBUTE_NORMAL. Then, pass in something like "C:\\temp"
(folder) or "D:\\" (drive). Note, the backslashes are doubled for the compiler, and you must
include the trailing backslashes for drive letters.