Help with CListCtrl GetItem(LVITEM*)

Help with CListCtrl GetItem(LVITEM*)

Post by DoranC » Sat, 27 Apr 2002 07:41:41



I have a CListCtrl widget in my dialog.  During OnInitDialog,
I set up a number of items/subitems for it.  The first SetItem
sets an image in the first column.  The call is something like
this....
    m_ReadList.InsertItem( ctrlidx, L"", imageN );
where ctrlidx is just the current row of my control and imageN is
an index value bew* 0 and 4.

Later on, I try to retrieve the image number with the
following function...

//***************************************************************************
int MyDialog::GetImageNumber(unsigned int idx)
{
    LVITEM item;

    item.iItem = idx;
    item.iSubItem = 0;
    item.mask = LVIF_IMAGE;

    m_ReadList.GetItem(&item);

    return item.iImage;

Quote:}

But the return value from this function is a huge number (which
I am assuming is just item.iImage's unitialised value), no matter
what item in my list ctrl I click on.

Any ideas why my function isn't filling in the iImage field
properly?

Thanks,
   DoranCat

 
 
 

Help with CListCtrl GetItem(LVITEM*)

Post by FunnyL » Sun, 28 Apr 2002 16:15:25


Quote:>-----Original Message-----
>I have a CListCtrl widget in my dialog.  During
OnInitDialog,
>I set up a number of items/subitems for it.  The first
SetItem
>sets an image in the first column.  The call is something
like
>this....
>    m_ReadList.InsertItem( ctrlidx, L"", imageN );
>where ctrlidx is just the current row of my control and
imageN is
>an index value bew* 0 and 4.

>Later on, I try to retrieve the image number with the
>following function...

>//********************************************************
*******************
>int MyDialog::GetImageNumber(unsigned int idx)
>{
>    LVITEM item;

>    item.iItem = idx;
>    item.iSubItem = 0;
>    item.mask = LVIF_IMAGE;

>    m_ReadList.GetItem(&item);

>    return item.iImage;
>}

>But the return value from this function is a huge number
(which
>I am assuming is just item.iImage's unitialised value),
no matter
>what item in my list ctrl I click on.

>Any ideas why my function isn't filling in the iImage
field
>properly?

>Thanks,
>   DoranCat>.

  The function of m_ReadList.GetItem(&item)  run fail, it
must be the reason: there is not a item in the list
control.You add a column only but not a item.

 
 
 

1. CListCtrl::GetItem

There are CListCtrl class members gettting and setting the text of items
and subitems. There is a class member for setting the lParam for items
and subitems. But as far as I can tell, there is no member to get the
lParam for a subitem. What I have done is to set the lParam in my
subitems to hold an integer representation that I use to sort. When it
is time to sort I would take the subitem's lParam and stuff it into the
item's lParam and then the built-in sort function would be all fat and
happy. But, so far, I can find no way to access the subitem's lParam
after I have set it. Anybody know how to do this?

Roger

2. XP startup errors

3. Does CListCtrl::GetItem suck?

4. Inbox folder in newsgroups???

5. CListCtrl ---- GetItem

6. Memory errors on exiting certain programs

7. How to use CListCtrl::GetItem()??

8. BIG Win95 memory problem - HELP!

9. Using GetItem in CListCtrl?

10. How to use ClistCtrl::GetItem??

11. CListCtrl : If you are using CListCtrl check this out.

12. CListCtrl: how to insert/ set subitems in a Report - CListCtrl

13. ADOCE using MFC OLE - Problem with Fields.GetItem()