Estoy intentado cargar en un ctreeview y un clistctrl con los
directorios y ficheros del sistema, y con su correspondiente icono en
cada entrada.
En los ordenadores con XP funciona sin problemas, pero bajo win2000 los
iconos no se corresponden para nada, incluso en los CFileDialog. Uso lo
siguiente:
CImageList sysImgList;
SHFILEINFO shFinfo;
sysImgList.Attach((HIMAGELIST)SHGetFileInfo("C:\\",
0,
&shFinfo,
sizeof( shFinfo ),
SHGFI_SYSICONINDEX |
SHGFI_SMALLICON ));
sysImgList.SetBkColor(RGB(0,0,0));
CBitmap bm;
bm.LoadBitmap(IDB_CARPETAS);
carpetitas = sysImgList.Add(&bm,RGB(0,0,0));
m_estructura.SetImageList( &sysImgList, TVSIL_NORMAL );
m_fichero.SetImageList(&sysImgList,LVSIL_SMALL);
sysImgList.Detach();
TCHAR szDrives[128];
TCHAR* pDrive;
TCHAR taux[4];
if (!GetLogicalDriveStrings(sizeof(szDrives)/sizeof(TCHAR),szDrives))
{
return FALSE;
}
pDrive = szDrives;
int iIcon,iIconIndex;
while(*pDrive)
{
SHGetFileInfo( pDrive,0,&shFinfo,sizeof( shFinfo
),SHGFI_ICON|SHGFI_SMALLICON);
iIcon = shFinfo.iIcon;
DestroyIcon(shFinfo.hIcon);
SHGetFileInfo( pDrive,0,&shFinfo,sizeof( shFinfo
),SHGFI_ICON|SHGFI_OPENICON|SHGFI_SMALLICON);
iIconIndex = shFinfo.iIcon;
DestroyIcon(shFinfo.hIcon);
strcpy(taux,pDrive);
taux[2] = '\0';
HTREEITEM item m_estructura.InsertItem(taux,iIcon,iIconIndex,NULL,TVI_SORT);
if (BuscaSubDirectorio(pDrive)) {
m_estructura.InsertItem(_T(""),0,0,item);
}
pDrive += _tcslen( pDrive ) + 1;
}
Hay alguna forma de que estos iconos se vean correctamente? No importa
bajo que SO lo compile.
Leer las respuestas