Announcement

Collapse
No announcement yet.

get pszText of a selected TreeViewItem

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

  • get pszText of a selected TreeViewItem

    Hi,
    I need to get the displayed Text of a selected TreeViewItem:

    I got the handle of a TreeViewItem:
    Code:
     'get handle of the selected item
    hItem&=TreeView_GetSelection(hTreeView&)
    ->that works!

    but how can I get the pszText (of the Item) now?

    -Uwe

    ------------------

  • #2
    Hi Uwe,

    This returns the text for a tree item having handle hItem -
    Code:
    function TVW_GetText( byval hTree as long, byval hItem as long ) as string
    
      'Purpose : Returns the item's text ; if the item is not found, returns ""
      '
      'Remarks : Allows max of 255 characters for tree item text
      '
      local ti      as TV_ITEM
      local zText   as asciiz * 256
      local s       as string
      
      'Set up the tree item structure for our purpose...
      ti.hItem      = hItem                              
      ti.mask       = %TVIF_TEXT                                  
      zText         = space$( 255 )                       
      ti.cchTextMax = 256                                
      ti.pszText    = varptr( zText )                                   
    
      'Query the tree...
      if TreeView_GetItem( hTree, ti ) = 0 then        'call failed             
        function = ""
      else
        s = zText
        function = s
      end if
    
    end function
    A book I've found really useful is Windows 95 Common Controls & Messages API Bible,
    by Richard J Simon, ISBN 1-57169-010-7. Also, you can download the free TinyHelp
    project from my web site which contains lots of useful treeview code.

    Regards,

    Paul


    ------------------
    http://www.zippety.net
    mailto[email protected][email protected]</A>
    Zippety Software, Home of the Lynx Project Explorer
    http://www.zippety.net
    My e-mail

    Comment

    Working...
    X