Announcement

Collapse
No announcement yet.

Treeview Get Image

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Lance Edmonds
    replied
    Of course, there are many ways to achieve the goal, but if one of our resident Custom Control guru's has created one already...

    BTW, 4600 items? Thats nothing! Try loading a treeview with 1,000,000 non-expanded sub-items, then press * at the root level. You can go away and comeback another day and it will still be running...

    While a million items seems excessive (and is probably bad app design to allow it), the TV control does allow it (although virtual memory gets a hammering at that level!)


    ------------------
    Lance
    PowerBASIC Support
    mailto:[email protected][email protected]</A>

    Leave a comment:


  • Paul Noble
    replied
    Thomas,

    I believe the correct way to set up item images to reflect their state is to use a state
    mask, which is a feature offered by the treeview control. In TinyHelp, I manage state
    images in code, simply because I had got it working before I discovered state masks. If
    you're interested in pursuing this, Rector & Newcomer cover it in detail. HTH -

    Lance,

    A virtual treeview eh, hmm. The Softel treeview control ( http://www.softelvdm.com ) has a
    virtual mode, but I think it's only when it's being used as a listview (ie: with
    only a single level of indentation). Also Sheridan (or whatever they're called these days)
    sell an ActiveX tree with two virtual modes - one mode retains data from 'ground covered',
    and the other always refreshes data as new ground is covered.

    Quite a job I'd say. To date I've been able to avoid the need for a virtual mode by, if
    necessary, delaying node population until the user demands a node expansion, for example
    when drilling down through client-server data. Also, I usually use WM_SETREDRAW to prevent
    the tree redrawing itself during loading and expanding, which provides an enormous speed
    increase. For example in Lynx, all nodes are populated when a project loads, and when
    loaded with the Lynx project itself, currently that's 4600 nodes, and they load seemingly
    instantly (shameless plug )

    But to return to your question, I imagine you'd implement such a scheme by populating
    tree nodes purely from a callback fired by the tree, or at least, from a worker thread
    acting on the tree's behalf. What's not clear is the algorithm you might use to determine
    which nodes need to be added to, for instance if you have some level of child-node
    expansion and the user then decides to scroll down some. Or even collapses a child node,
    at some level of indentation. 'Gives me a headache just thinking about it

    Regards,

    Paul


    ------------------
    http://www.zippety.net
    mailto[email protected]ety.net[email protected]</A>

    Leave a comment:


  • Thomas Noelker
    Guest replied
    Lance,

    Yes Sir, absolutely. That was the mistake iSelectedImage - Stupid.

    Thanks.
    Thomas


    ------------------
    [email protected]

    Leave a comment:


  • Lance Edmonds
    replied
    You are only setting the non-selected image (TI.iImage). Why not specify the TI.iSelectedImage when you add the item initially to the treeview?

    If necessary, you can refresh the control with CALL UpdateWindow(hTree), but it seems that you just need to adjust your approach slightly.

    BTW, anyone written a virtual-treeview (something faster than the native Windows one?). (hint hint!)


    ------------------
    Lance
    PowerBASIC Support
    mailto:[email protected][email protected]</A>

    Leave a comment:


  • Thomas Noelker
    Guest replied
    Paul,

    I should better take a look before the other reply!
    I think the Tiny Help answers all my questions.

    Good job.
    Many Thanks.
    Thomas


    ------------------
    [email protected]

    Leave a comment:


  • Thomas Noelker
    Guest replied
    Thanks guys,

    last question about this.
    Is there anything wrong with this snippet?
    Because, if I click onto a node. Not this image is changed but the
    image of the node I'm leaving I mean from the previous node. I don't get it.


    CASE %WM_NOTIFY
    tagNMHDR = CBLPARAM
    IF (@tagNMHDR.Code = %TVN_SELCHANGED) AND _
    (@tagNMHDR.IdFrom = %ID_TREE) THEN
    hTV = CBLPARAM
    i = @hTV.ItemNew.hItem
    pItem.hItem = i
    pItem.mask = %TVIF_TEXT OR %TV_IMAGE
    pItem.pszText = VARPTR(zt) 'get the text
    pItem.cchTextMax = %MAX_PATH
    TreeView_GetItem @tagNMHDR.hWndFrom, pItem
    '// here I try to change the image
    pItem.hItem = i 'this one and the next one should be still in struct but just in case
    pItem.mask = %TVIF_TEXT OR %TV_IMAGE
    pItem.iImage = newimage_index
    TreeView_SetItem @tagNMHDR.hWndFrom, pItem
    END IF

    Is there a refresh needed for the control? If yes please how?

    Thanks ahead
    Thomas


    ------------------
    [email protected]

    Leave a comment:


  • Paul Noble
    replied
    Thomas,

    If you download the free TinyHelp project from my web site, you'll find it includes
    a function TVW_GetImage() that does does exactly this. The project also includes lots
    more useful code, including code for the treeview control.

    Here's the function -
    Code:
      function TVW_GetImage( byval hTree as long, byval hItem as long ) as long
    
        'Purpose : Returns the ordinal of the item's bitmap ; if the item is not
        '          found, returns -1
        '
        local ti as TV_ITEM
    
        ti.hItem = hItem                                              'set up the item structure
        ti.mask  = %TVIF_HANDLE or %TVIF_IMAGE                        'these are the valid fields
    
        if TreeView_GetItem( hTree, ti ) = 0 then                     'fetch info about the new item
          function = -1
        else
          function = ti.iImage
        end if
    
      end function
    Regards,

    Paul


    ------------------
    http://www.zippety.net
    mailto[email protected][email protected]</A>

    Leave a comment:


  • Lance Edmonds
    replied
    It's been a while, but I believe you use send a %TVM_GETITEM message to the control and the image index number is found in the TV_ITEM structure that is filled by the control.


    ------------------
    Lance
    PowerBASIC Support
    mailto:[email protected][email protected]</A>

    Leave a comment:


  • Thomas Noelker
    Guest started a topic Treeview Get Image

    Treeview Get Image

    Hi there,
    does anyone know how to get the index of an image from the selected item
    in a treeview control. It's propably simple. I've beeing searching
    up and down in all forums but couldn't find any answer yet.

    Thanks ahead.
    Thomas



    ------------------
    [email protected]
Working...
X