Hi,
I need some help with WinAPI.
I've created a listview control with 5 columns (using LVM_INSERTCOLUMN message) and prepared the ImageList:
Code:
SHFILEINFO shfi;
HIMAGELIST imglist;
if (SHGetFileInfo(L"C:\\Windows\\System32\\AdapterTroubleshooter.exe", 0, &shfi, sizeof(SHFILEINFO), SHGFI_ICON | SHGFI_SMALLICON) == 0){
MessageBox(hWnd, L"Error getting file info.", L"ERROR", MB_ICONERROR);
}
imglist = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR32, 1, 1);
ImageList_AddIcon(imglist, shfi.hIcon);
ListView_SetImageList(listbox, imglist, LVSIL_SMALL);
(listbox is actually HWND handle for ListView)
Then I add items:
Code:
SendMessage(listbox, LVM_INSERTITEM, 0, (LPARAM) &omfg);
omfg.iSubItem = 0;
omfg.pszText = buffer1;
SendMessage(listbox, LVM_SETITEM, 0, (LPARAM) &omfg);
omfg.iSubItem = 1;
omfg.pszText = buffer2;
SendMessage(listbox, LVM_SETITEM, 0, (LPARAM) &omfg);
(omfg is a LVITEM structure)
And here comes the problem: as it turns out, there's no way to specify in which column (iSubItem) the image should be placed. No matter what I do, the image is always displayed in the first column. Since I needed to place the image in the last (fifth) column, I've tried putting -1 to the iImage member of LVITEM structure, and then changing it to 0 before sending message for iSubItem = 4, but this had no effect: the image was still in the first column.
By commenting out lines of code, I've figured out that the image has already been placed in the first column after LVM_INSERTITEM message has been sent.
So the question is: how do I place the image in the fifth column of the listview?