Link to outside data in list view

This is a discussion on Link to outside data in list view within the Windows Programming forums, part of the Platform Specific Boards category; Hi all, I have a list view that has been populated with data according to a value located in a ...

  1. #1
    Registered User eth0's Avatar
    Join Date
    Dec 2003
    Posts
    164

    Link to outside data in list view

    Hi all,

    I have a list view that has been populated with data according to a value located in a separate pointer array.
    This value however is not included in the list view.

    When I double click a row, I need to be able to link back to this original data which assigned what was put in the row.

    I ideally need to save a pointer to this data for each row in the list view.

    I'm not sure how or if this can be done, or if there is a better way.

    Please advise.

    Thanks.
    Open source isn't a matter of life or death......
    .......its much more important than that!!


    SuSE Linux - GCC 3.4.2
    XP Pro - Visual Studio 2005 TS, MinGW 3.4.2

  2. #2
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,246
    I ideally need to save a pointer to this data for each row in the list view.
    You can do this. In the LVITEM structure, there is a member named lParam. Set this lParam value to your pointer before you send the LVM_SETITEM message.

  3. #3
    Registered User eth0's Avatar
    Join Date
    Dec 2003
    Posts
    164
    Thanks for the reply.
    I'm assigning a value to lParam, but it doesn't appear to be carrying it over.

    I'm using the following :


    This is now in the loop assigning each list item to have a number (for testing)
    Code:
    item.lParam = Index;
    double clicking an item sends the NM_DBLCLK message
    Code:
    case WM_NOTIFY:
    {
        switch (((LPNMHDR) lParam)->code)
        {
            LPNMITEMACTIVATE nmitem;
    
    	case NM_DBLCLK:
                nmitem = (LPNMITEMACTIVATE)lParam;
                GetData(nmitem->lParam);
            break;
    ...
    Other data in the NMITEMACTIVATE structure like iItem and iSubItem are passed as expected. However I'm getting nonsense values in the lParam.

    What is going wrong?

    Thanks
    Open source isn't a matter of life or death......
    .......its much more important than that!!


    SuSE Linux - GCC 3.4.2
    XP Pro - Visual Studio 2005 TS, MinGW 3.4.2

  4. #4
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,246
    After you receive the double-click, send the LVM_GETITEM message to get the correct item (Use the iItem and iSubItem values in your nmitem to get the correct LVITEM). Then use the lParam member of the LVITEM structure.

  5. #5
    Registered User eth0's Avatar
    Join Date
    Dec 2003
    Posts
    164
    It doesn't appear to be filling in the lParam value. The lParam value is set to 0 every time the LVM_GETITEM call is made

    Code:
            case WM_NOTIFY:
            {
                switch (((LPNMHDR) lParam)->code)
                {
                    LPNMITEMACTIVATE nmitem;
                    LVITEM item;
    
                    case NM_DBLCLK:
                        nmitem = (LPNMITEMACTIVATE) lParam;
    
                        item.mask = LVIF_PARAM;
                        item.iItem = nmitem->iItem;
                        item.iSubItem = nmitem->iSubItem;
    
                        //SendMessage(hListView, LVM_GETITEM, 0, (LPARAM)&item);
                        ListView_GetItem(hListView, &item); // upon return, lParam is 0
    
                        GetData(item.lParam);
                    break;
    ...
    Any ideas?
    Open source isn't a matter of life or death......
    .......its much more important than that!!


    SuSE Linux - GCC 3.4.2
    XP Pro - Visual Studio 2005 TS, MinGW 3.4.2

  6. #6
    Registered User eth0's Avatar
    Join Date
    Dec 2003
    Posts
    164
    fixed.
    I had forgotten to include the LVIF_PARAM mask when inserting the item.
    Open source isn't a matter of life or death......
    .......its much more important than that!!


    SuSE Linux - GCC 3.4.2
    XP Pro - Visual Studio 2005 TS, MinGW 3.4.2

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Linked List, Please Help!
    By CodeMonkeyZ in forum C Programming
    Replies: 5
    Last Post: 02-17-2009, 06:23 AM
  2. Unknown memory leak with linked lists...
    By RaDeuX in forum C Programming
    Replies: 6
    Last Post: 12-07-2008, 04:09 AM
  3. Replies: 48
    Last Post: 09-26-2008, 04:45 AM
  4. Following CTools
    By EstateMatt in forum C Programming
    Replies: 5
    Last Post: 06-26-2008, 11:10 AM
  5. singly linked list
    By clarinetster in forum C Programming
    Replies: 2
    Last Post: 08-26-2001, 11:21 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21