Primeramente decirles que soy novato en esto de la programacion con las apis de windows y tambien en c
el detalle es que el programa se supone que deberia de listar los nombres y los iconos de los directorios que se encuentran en c:\ y si muestra los nombres pero el problema es con los iconos que solo muestra un mismo icono para todos
el codigo es el siguiente y lo estoy haciendo en vc++ 6.0
les agradeceria cualquier sugerencia y muchas gracias a todos

el detalle es que el programa se supone que deberia de listar los nombres y los iconos de los directorios que se encuentran en c:\ y si muestra los nombres pero el problema es con los iconos que solo muestra un mismo icono para todos
el codigo es el siguiente y lo estoy haciendo en vc++ 6.0
Código [Seleccionar]
#include <windows.h>
#include <stdio.h>
#include <commctrl.h>
#pragma comment(lib, "comctl32.lib")
#define ID_LISTVIEW 1
char directory[500]="C:\\";
typedef struct
{
char szItem[100];
}Item;
BOOL AdjustListView(HWND hList, LV_ITEM *lv, int iItems)
{
int i = iItems;
// int iRet;
ListView_DeleteAllItems(hList);
lv->mask = LVIF_TEXT;
lv->iSubItem = 0;
lv->pszText = LPSTR_TEXTCALLBACK;
while(i > 0)
{
ListView_InsertItem(hList, lv);
i--;
}
return TRUE;
}
BOOL WINAPI InitListViewImageLists(HWND hwndLV, char nFile[500])
{
// HIMAGELIST himlLarge; // image list for icon view
HIMAGELIST himlSmall; // image list for other views
SHFILEINFO nFileInfo;
// Create the full-sized and small icon image lists.
//himlLarge = ImageList_Create(GetSystemMetrics(SM_CXICON),
// GetSystemMetrics(SM_CYICON), TRUE, 1, 1);
himlSmall = ImageList_Create(GetSystemMetrics(SM_CXSMICON),
GetSystemMetrics(SM_CYSMICON), TRUE, 1, 1);
// Add an icon to each image list.
SHGetFileInfo(nFile, FILE_ATTRIBUTE_NORMAL, &nFileInfo, sizeof(nFileInfo), SHGFI_ICON | SHGFI_SMALLICON);
//ImageList_AddIcon(himlLarge, nFileInfo.hIcon);
ImageList_AddIcon(himlSmall, nFileInfo.hIcon);
// Assign the image lists to the list view control.
//ListView_SetImageList(hwndLV, himlLarge, LVSIL_NORMAL);
ListView_SetImageList(hwndLV, himlSmall, LVSIL_SMALL);
return TRUE;
}
LRESULT CALLBACK WndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
{
static CREATESTRUCT *cs;
static HWND hWndListView;
static HFONT hFont;
static LV_ITEM lv;
static Item listitemm;
static Item* ListItem;// = (Item* )LocalAlloc(LPTR, sizeof(Item));
int i;
HANDLE hFile;
LV_COLUMN lvC;
RECT rect;
char path[500];
char temp[500];
strcpy(path,directory);
strcat(path,"*.*");
WIN32_FIND_DATA data;
LV_DISPINFO *lvd;
NMHDR *hdr;
ListItem = &listitemm;
switch (iMsg)
{
case WM_CREATE :
cs = (CREATESTRUCT *)lParam;
hWndListView = CreateWindowEx(WS_EX_CLIENTEDGE, WC_LISTVIEW,
"", WS_VISIBLE | WS_CHILD | LVS_SHOWSELALWAYS | LVS_LIST | LVS_ICON ,
0, 0, 0, 0, hwnd,(HMENU)ID_LISTVIEW, cs->hInstance, NULL);
ListView_SetExtendedListViewStyle(hWndListView, LVS_EX_FULLROWSELECT);
lvC.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
lvC.fmt = LVCFMT_LEFT;
hFile = FindFirstFile(path, &data);
strcpy(ListItem->szItem, data.cFileName);
strcpy(temp, directory);
strcat(temp,data.cFileName);
//InitListViewImageLists(hWndListView, temp);
//AdjustListView(hWndListView, &lv, 1);
lvC.iSubItem = 0;
lvC.cx = 100;
i=1;
while(FindNextFile(hFile,&data)!=0)
{
strcpy(temp, directory);
strcat(temp,data.cFileName);
strcpy((ListItem+i)->szItem, data.cFileName);
i++;
InitListViewImageLists(hWndListView, temp);
AdjustListView(hWndListView, &lv, i);
}
FindClose(hFile);
break;
case WM_SIZE :
GetClientRect(hwnd, &rect);
MoveWindow(hWndListView, 3, 3, rect.right - 6, rect.bottom - 6, 1);
break;
case WM_NOTIFY :
switch(((LPNMHDR)lParam)->code)
{
case NM_DBLCLK :
hdr = (NMHDR FAR*)lParam;
if(hdr->hwndFrom == hWndListView)
{
// index = ListView_GetNextItem(hWndListView,-1,LVNI_SELECTED);
/* if(index != -1)
{
MessageBox(hwnd, ListItem[index].szItem, "Doubleclicked on this item", MB_OK);
}*/
}
break;
case LVN_GETDISPINFO :
lvd = (LV_DISPINFO FAR*)lParam;
if((((LPNMHDR)lParam)->hwndFrom == hWndListView))
{
if(lvd->item.iSubItem==0)
{
lvd->item.pszText = ListItem[lvd->item.iItem].szItem;
}
break;
}
}
break;
case WM_CLOSE :
DestroyWindow(hwnd);
break;
case WM_DESTROY :
DeleteObject(hFont);
PostQuitMessage(0);
break;
}
return DefWindowProc(hwnd, iMsg, wParam, lParam);
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
{
HWND hwnd;
MSG msg;
WNDCLASS wndclass;
char szAppName[] = "ListviewApp";
INITCOMMONCONTROLSEX icex;
wndclass.style = 0;
wndclass.lpfnWndProc = WndProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hInstance = hInstance;
wndclass.hIcon = LoadIcon(hInstance, szAppName);
wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
wndclass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
wndclass.lpszMenuName = szAppName;
wndclass.lpszClassName = szAppName;
RegisterClass(&wndclass);
icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
icex.dwICC = ICC_LISTVIEW_CLASSES;
InitCommonControlsEx(&icex);
hwnd = CreateWindow(szAppName, szAppName,
WS_OVERLAPPEDWINDOW | WS_VISIBLE, 100, 100, 600, 250,
NULL, NULL, hInstance, szCmdLine);
while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return (int)msg.wParam;
}
les agradeceria cualquier sugerencia y muchas gracias a todos