Virtual CListCtrl Question 
Author Message
 Virtual CListCtrl Question

Hi, my app uses a CListView in "virtual mode" (LVS_OWNERDATA style),
however i cant get the list view to give me its item data! on my
LVM_GETDISPINFO handler i do this:

if (pnmv->item.mask & LVIF_PARAM)
{
        pnmv->item.lParam = (LPARAM)m_pSet->m_ItemCode;    // m_itemcode is
a long value from a recordset.

Quote:
}

if(pnmv->item.mask & LVIF_TEXT)
{
        ...........pass the text

Quote:
}

and then later when i want to get the lParam (item data) for a particular
item i do this:

int selected = GetSelectedIndex();    // this returns the index of the
selected item (or -1 if none)

if(selected == -1)
        return;
long mycode=(long)GetListCtrl().GetItemData(selected); //THIS ALLWAYS
RETURNS ZERO!!

it will allways return zero, no matter what item i pass to GetItemData();

Any idea of what could be wrong????



Wed, 14 Sep 2005 10:21:20 GMT  
 Virtual CListCtrl Question

Quote:
> Hi, my app uses a CListView in "virtual mode" (LVS_OWNERDATA style),
> however i cant get the list view to give me its item data! on my
> LVM_GETDISPINFO handler i do this:

> if (pnmv->item.mask & LVIF_PARAM)
> {
>         pnmv->item.lParam = (LPARAM)m_pSet->m_ItemCode;    // m_itemcode
is
> a long value from a recordset.
> }

> if(pnmv->item.mask & LVIF_TEXT)
> {
>         ...........pass the text
> }

> and then later when i want to get the lParam (item data) for a particular
> item i do this:

> int selected = GetSelectedIndex();    // this returns the index of the
> selected item (or -1 if none)

> if(selected == -1)
>         return;
> long mycode=(long)GetListCtrl().GetItemData(selected); //THIS ALLWAYS
> RETURNS ZERO!!

> it will allways return zero, no matter what item i pass to GetItemData();

> Any idea of what could be wrong????

I read the documentation on NMLVDISPINFO (or LV_DISPINFO), which states that
only the following masks can be set for LVN_GETDISPINFO:
* LVIF_IMAGE
* LVIF_STATE
* LVIF_TEXT

If you debug your code, you will notice that your LPARAM value isn't even
set in the handler for LVN_GETDISPINFO.

I think this means that you can't set LPARAM values this way, and I don't
know of any other way.

Tom.



Wed, 14 Sep 2005 11:26:45 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Virtual CListCtrl Question

2. Virtual CListCtrl with DAORecordset question

3. CListCtrl : Do checkboxes (LVS_EX_CHECKBOXES) work with the virtual CListCtrl (LVS_OWNERDATA)

4. Virtual CListCtrl ListBox

5. A virtual clistctrl with checkboxes.

6. Virtual CListCtrl scroll problem

7. virtual CListCtrl

8. Problems with Virtual CListCtrl on a FormView

9. Icon thread? (OnGetDispInfo, Virtual CListCtrl's)

10. Disable real-time scrolling with a virtual CListCtrl containing more than 32767 lines

11. How: colors in virtual CListCtrl????

12. DrawItem() not called for CListCtrl in virtual mode?

 

 
Powered by phpBB® Forum Software