CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2005
    Posts
    9

    tree view get info from selected item

    Hello, i have a tree view control with lots of items. I wanna to make context menu to each item (due to lets say its bmp image in tree) on right click.
    Everything works perfect, I can get HTREEITEM of selected item with right click, but I am not sure how to continue.
    The selected item - HTREEITEM - is in Selected (or also in tinf.hItem, I suppose): Selected = TreeView_HitTest(hTree, &tinf); //WORKS

    I thought I should do something like this (to find out if selected item has g_Image1 bitmap):

    TVITEM item;
    item.hItem = tinf.hItem; (or Selected)
    item.iImage = g_Image1;
    item.iSelectedImage = g_Image1;
    item.mask = TVIF_SELECTEDIMAGE | TVIF_IMAGE;

    and then call some:

    SendDlgItemMessage(hwnd, IDC_TREE, TVM_GETITEM, TVGN_CARET, (LPARAM)&item); (to retrieve complet data to the same item, and access it later) ... but this doesnt works.

    Did I missunderstand it? How can I get some info from selected item if I have only its HTREEITEM .
    Thank YOU.

  2. #2
    Join Date
    Feb 2003
    Location
    California
    Posts
    334

    Re: tree view get info from selected item

    Why are you setting iImage and iSelectedImage? Set hItem only, since that is what you are searching on.
    Henri Hein
    Principal Engineer, Propel
    Do not credit Propel with my views or opinions.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured