Displaying folder icons in an XP TreeView control
1. Create TreeView control and ImageList; add system icons to ImageList and attach it to the TreeView. In Windows XP, these
system icons are 32-bit which includes a 8-bit transparency alpha channel, so unless you can make your own icons which
will look nice like that, you'll want to use the system icons, which can be viewed here
hwndTV = CreateWindowEx(WS_EX_CLIENTEDGE,WC_TREEVIEW,g_wszNull,
hil = ImageList_Create(16,16,ILC_COLOR32,10,10);
HMODULE hmod = LoadLibraryA("shell32");
hi = LoadIcon(hmod,MAKEINTRESOURCE(4)); // closed folder
hi = LoadIcon(hmod,MAKEINTRESOURCE(5)); // open folder
2. For Windows XP, to use the 32-bit icons, you must now mark your application manifest as ComCtl32 version 6 compilant. Name this file YourApp.exe.manifest
, save it in UTF8 format (using notepad) and put it in the directory with your executable. You can also include it in the executable as resource number 1 of type RT_MANIFEST.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
3. If you want to use ImageList_DrawIndirect
and the new members of IMAGELISTDRAWPARAMS
to manually draw the 32-bit icons, you'll have to set _WIN32_WINNT = 0x501 before including windows.h. This causes the cbSize member to be a larger value at compile-time, indicating your app's desire to use new version 6 functionality.