Note that there are some explanatory texts on larger screens.

plurals
  1. POTrying to create HIMAGELIST, what am I doing wrong here?
    primarykey
    data
    text
    <p>I want to create an <code>HIMAGELIST</code> for the list view. It actually needs to consist of file icons.</p> <p>Here's the code I have:</p> <pre><code>HIMAGELIST imageList = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_MASK, 1, 1); HICON ico = reinterpret_cast&lt;HICON&gt;(LoadImage(0,IDI_APPLICATION, IMAGE_ICON,0,0,LR_SHARED)); ImageList_AddIcon(imageList, ico); ListView_SetImageList(listView, imageList, LVSIL_SMALL); </code></pre> <p>The list view with three elements now has three application items.</p> <p>However when I try to add another icon (<code>IDI_HAND</code> in this case), I still get the same 3 icons.</p> <p>Another problem I have is that I can't fetch the actual file icons I need:</p> <pre><code>SHFILEINFO sfi; SHGetFileInfo (L"C:\\test.txt", NULL, &amp;sfi, sizeof (sfi), SHGFI_SYSICONINDEX | SHGFI_SMALLICON); ImageList_AddIcon(imageList, sfi.hIcon); </code></pre> <p>This results in empty icons, not the <code>txt</code> icons I want.</p> <p>I've been struggling with this for ever, and I greatly appreciate your help here.</p> <p><em>UPDATE</em></p> <p>I'm using sample code I found on the Internet to fill the list view (obviously that's not what I want):</p> <pre><code>UINT columnMask = LVCF_TEXT|LVCF_FMT|LVCF_SUBITEM|LVCF_WIDTH; LVCOLUMN lc[] = { { columnMask, 0, 150, L"Text...",0, 0,0,0 }, { columnMask, LVCFMT_CENTER, 70, L"Number",0, 1,0,0 }, { columnMask, 0, 100, L"Whatever",0, 2,0,0 }, }; ListView_InsertColumn(listView, 0, &amp;lc[0]); ListView_InsertColumn(listView, 1, &amp;lc[1]); ListView_InsertColumn(listView, 2, &amp;lc[2]); UINT itemMask = LVIF_TEXT; LVITEM li[] = { { itemMask, 0,0, 0,0, L"...for the first item!",0, 0,0,0,0,0,0 }, { itemMask, 0,1, 0,0, L"1",0, 0,0,0,0,0,0 }, { itemMask, 0,2, 0,0, L"14 bucks",0, 0,0,0,0,0,0 }, { itemMask, 1,0, 0,0, L"...for the second item!",0, 0,0,0,0,0,0 }, { itemMask, 1,1, 0,0, L"24",0, 0,0,0,0,0,0 }, { itemMask, 1,2, 0,0, L"2 suns",0, 0,0,0,0,0,0 }, { itemMask, 2,0, 0,0, L"...for the second item!",0, 0,0,0,0,0,0 }, { itemMask, 2,1, 0,0, L"24",0, 0,0,0,0,0,0 }, { itemMask, 2,2, 0,0, L"2 suns",0, 0,0,0,0,0,0 }, { itemMask, 3,0, 0,0, L"...for the second item!",0, 0,0,0,0,0,0 }, { itemMask, 3,1, 0,0, L"24",0, 0,0,0,0,0,0 }, { itemMask, 3,2, 0,0, L"2 suns",0, 0,0,0,0,0,0 }, }; // setting an icon like this doesn't work li[0].iImage = sfi.iIcon; ListView_InsertItem(listView, &amp;li[0]); ListView_SetItem(listView, &amp;li[1]); ListView_SetItem(listView, &amp;li[2]); ListView_InsertItem(listView, &amp;li[3]); ListView_SetItem(listView, &amp;li[4]); ListView_SetItem(listView, &amp;li[5]); ListView_InsertItem(listView, &amp;li[6]); ListView_SetItem(listView, &amp;li[7]); ListView_SetItem(listView, &amp;li[8]); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload