CXListCtrl
(1)
CImageList
(1)
CListCtrl
(1)
Lvi1.iSubItem
(1)
ListControl
(1)
OImageList
(1)
PListCtrl
(1)
GetItem
(1)

Not getting image index from ListControl

Asked By Krishna
19-Jan-10 10:10 AM
Context of usage :
There is a ListControl(Class CXListCtrl derived from CListCtrl )in dialog
box. This ListControl is associated with Bitmaps list(CImageList
m_oImageList). The Bitmap list contains 6 images.
One of the column in ListControl is set with bitmap image. Please see code .
LVITEM lvi;
lvi.mask =  LVIF_IMAGE;
lvi.iItem = pResult->nItem-1;
lvi.iSubItem = 5;
lvi.iImage = 3;
pListCtrl->SetItem(&lvi);

it is displaying the bitmap in desired row and column. In our code we need to
get the image details(image index) associated with this particular column in
some other place(GetItem is called). GetItem() is not giving the image index.
I used the following code immediately after SetItem to check whether the
function is working or not.

LVITEM lvi1;
lvi1.mask =  LVIF_IMAGE;
lvi1.iItem = pResult->nItem-1;
lvi1.iSubItem = 5;
pListCtrl->GetItem(&lvi1);

After this code execution the lvi1.iImage should contain the value 3.
Note : The class CXListCtrl has not implemented the SetItem() and GetItem().
So it is calling the functions of base class CListCtrl.

Expected behavior (Document reference of MS) :
GetItem(&lvi1) -> should get the item details.
lvi1.iImage -> This field should contain the index of the image in control's
image list

Document Reference : MSDN, CListCtrl->Members->GetItem .

Actual behavior :
It???s giving some junk value in iImage field.

Please inform me if you need more information.

Best Regards,
Venkat

--
Regards
Krishna
Post Question To EggHeadCafe