Hi guys
I have a problem with inserting icons in my listview.
When I push the button I'd like to insert some icons in the listview.
I have noticed when I run my code some place is captured(where a possible icon must be)?BUT icons aren't displayed.
Please help me with that !!!
Here is my simple code:
#define IDI_ICON1 111
#define IDI_ICON2 112
#define IDI_ICON3 113
#define IDI_ICON4 114
#define IDI_ICON5 115
#define IDI_ICON6 116
hFileListView=CreateWindow(WC_LISTVIEW,
NULL,
WS_CHILD | WS_VISIBLE | LVS_REPORT|WS_HSCROLL|WS_BORDER|WS_VSCROLL |
ES_AUTOHSCROLL | ES_AUTOVSCROLL,
150,
70,
630,
220,
hWnd,
(HMENU) 500,
hInst,
NULL);
lvc.mask = LVCF_TEXT | LVCF_SUBITEM | LVCF_WIDTH | LVCF_FMT;
lvc.fmt = LVCFMT_LEFT;
lvc.iSubItem = 0;
lvc.cx = 280;
lvc.pszText = TEXT("Name");
ListView_InsertColumn(hFileListView, 0, &lvc);
lvc.iSubItem = 1;
lvc.cx = 150;
lvc.pszText = TEXT("Data Modified");
ListView_InsertColumn(hFileListView, 1, &lvc);
lvc.iSubItem = 2;
lvc.cx = 100;
lvc.pszText = TEXT("Type");
ListView_InsertColumn(hFileListView, 2, &lvc);
lvc.iSubItem = 3;
lvc.cx = 100;
lvc.pszText = TEXT("Size");
ListView_InsertColumn(hFileListView, 3, &lvc);
typedef struct tagAPPLINFO
{
char szAppName[40];
char szIconName[20];
}APPLINFO;
APPLINFO rgApplInfo[]=
{
{"Folder", "book1.ico"},
{"Exe", "exec.ico"},
{"Music", "music.ico"},
{"Text", "text.ico"},
{"Undefined", "unkn.ico"},
{"Picture", "picture.ico"},
{"Dll", "Dll.ico"}
};
VOID InsertInFileList(HWND hWnd,HWND hFileListView,LVITEM lv,HIMAGELIST himl,HINSTANCE hInst){
HICON hIcon;
himl=ImageList_Create(
GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_MASK, 1, 1);
for(int i = IDI_ICON1; i <= IDI_ICON6; i++)
{
hIcon = LoadIcon(hInst,MAKEINTRESOURCE(i));
ImageList_AddIcon(himl, hIcon);
}
ListView_SetImageList(hFileListView, himl, LVSIL_SMALL);
for(int i=0; i<6; i++)
{
lv.iItem=0;
lv.iSubItem = 0;
lv.cchTextMax = 40;
lv.lParam = (LPARAM)&rgApplInfo[1];
lv.iImage = i;
ListView_InsertItem(hFileListView, &lv);
ListView_SetItemText(hFileListView, 0, 0, TEXT("1"));
}
}