From: Arthur on
I have a CListCtrl, with the extended style LVS_EX_SUBITEMIMAGES enabled
to let me have images on the subitems.

Now is it possible the have different images in each column on the same
row? No matter what I do, I always get the same image in every column.

I've tried using the I_IMAGECALLBACK callback, then setting the image to
something different based on what subitem is being drawn, but still no luck.

Any ideas?

Arthur
From: AliR on
Is this what you are doing to set the image of the subitem?

SetItem(nItem, nSubItem, LVIF_IMAGE, NULL, nImageIndex, 0, 0, 0);

Are you sure you are passing the correct image id?

If you can't get it working take a look at this:
http://www.codeproject.com/listctrl/ReportControl.asp

AliR.

"Arthur" <arthur(a)fubaby.com> wrote in message
news:NNs1f.19424$OC3.8498(a)newsfe5-win.ntli.net...
> I have a CListCtrl, with the extended style LVS_EX_SUBITEMIMAGES enabled
> to let me have images on the subitems.
>
> Now is it possible the have different images in each column on the same
> row? No matter what I do, I always get the same image in every column.
>
> I've tried using the I_IMAGECALLBACK callback, then setting the image to
> something different based on what subitem is being drawn, but still no
luck.
>
> Any ideas?
>
> Arthur


From: Arthur on
I've been using the LVITEM structure to add entries, like this:-

CString number;
LVITEM lvitem;
lvitem.iItem = 0;
lvitem.mask = LVIF_TEXT | LVIF_PARAM | LVIF_IMAGE;
lvitem.lParam = si.m_ID;
lvitem.iImage = si.m_GameVersion;
lvitem.iSubItem = kID;
number.Format(_T("%d"), si.m_InGameID);
lvitem.pszText = number.GetBuffer(number.GetLength());
lvitem.iItem = m_ResultsCtrl.InsertItem(&lvitem);

lvitem.mask = LVIF_TEXT;
lvitem.iSubItem = kSongTitle;
lvitem.pszText = si.m_SongTitle.AllocSysString();
m_ResultsCtrl.SetItem(&lvitem);

lvitem.mask = LVIF_TEXT | LVIF_IMAGE;
lvitem.iSubItem = kStatus;
lvitem.pszText = L"";
lvitem.iImage = 12;
m_ResultsCtrl.SetItem(&lvitem);

This was my first test. 'si' is just another class of mine which I grab
values out of to present in the CListCtrl, which is the var
m_ResultsCtrl. The iSubItem values are just from an enum.
The above code gives me the different and correct icons in the far left
column (for m_GameVersion), however I don't get the same icon in the
kStatus column, I just get the same icon as the first column.

I then tried replacing the latter chunk of code with:-

lvitem.mask = LVIF_TEXT | LVIF_IMAGE;
lvitem.iSubItem = kStatus;
lvitem.pszText = L"";
lvitem.iImage = I_IMAGECALLBACK;
m_ResultsCtrl.SetItem(&lvitem);

Then in the class derived from CListCtrl I have this function:-

void CSongSelectListCtrl::OnLvnGetdispinfo(NMHDR *pNMHDR, LRESULT *pResult)
{
NMLVDISPINFO *pDispInfo = reinterpret_cast<NMLVDISPINFO*>(pNMHDR);

LV_ITEM *pItem = &((LV_DISPINFO*)pNMHDR)->item;

if( pItem->mask & LVIF_IMAGE )
{
if ( pItem->iSubItem != CMainDialog::kID )
pItem->iImage = I_IMAGENONE;
else if ( pItem->iSubItem == CMainDialog::kStatus )
pItem->iImage = 12;
}
*pResult = 0;
}

Again I get the same results as before and completely ignores what value
I give the iImage. Although it does seem to pay attention to the
I_IMAGENONE constant. Any positive value for any column just gives an
icon the same as the first column in the control.

Stepping through with a debugger, on entry to the above function, iImage
is always the value of the first column.

Any more ideas?

I'll have a look at the ReportControl you recommend in the mean time though.

Arthur.

AliR wrote:
> Is this what you are doing to set the image of the subitem?
>
> SetItem(nItem, nSubItem, LVIF_IMAGE, NULL, nImageIndex, 0, 0, 0);
>
> Are you sure you are passing the correct image id?
>
> If you can't get it working take a look at this:
> http://www.codeproject.com/listctrl/ReportControl.asp
>
> AliR.
>
> "Arthur" <arthur(a)fubaby.com> wrote in message
> news:NNs1f.19424$OC3.8498(a)newsfe5-win.ntli.net...
>
>>I have a CListCtrl, with the extended style LVS_EX_SUBITEMIMAGES enabled
>>to let me have images on the subitems.
>>
>>Now is it possible the have different images in each column on the same
>>row? No matter what I do, I always get the same image in every column.
>>
>>I've tried using the I_IMAGECALLBACK callback, then setting the image to
>>something different based on what subitem is being drawn, but still no
>
> luck.
>
>>Any ideas?
>>
>>Arthur
>
>
>