Re: Iterating Through TreeView Children

new topic     » goto parent     » topic index » view thread      » older message » newer message

CK,

If you insert these two routines into Win32Lib.ew right after the deleteItem()
routine you will be able to:

1. Get all children of any tree view item
2. Delete children of any tree view item.

I thought these might make their way into the official Win32Lib one day, I seem
to remember submitting them to Derek.

HTH,

--BEG CJT01
-----------------------------------------------------------------------------
--/topic Tree View Control
--/func deleteTVChildren( TheTreeView, position )
--/desc Deletes all children at "position" in the /i tree view.
--
-- Example:
--/code
--          atom position
--          position = getTVIndex(TheTreeView)
--          /deleteTVChildren( TheTreeView, position )
--/endcode

global procedure deleteTVChildren( atom id, integer pos )

    atom iItem

    -- Is a treeview?
    if ctrl_Type[ id ] = TreeView then
        -- take care of any children
        iItem = find(pos, tvitem_parent)
        while iItem do
            VOID = deleteItem( id, iItem )
	        iItem = find(pos, tvitem_parent)
        end while
    end if

end procedure

-----------------------------------------------------------------------------
--/topic Tree View Control
--/func getTVChildren( TheTreeView, position )
--/desc Returns all child items for the passed item in the /i tree view.
--
-- Example:
--/code
--          atom position
--          sequence children
--
--          position = getTVIndex(TheTreeView)
--          children = /getTVChildren( TheTreeView, position )
--/endcode

global function getTVChildren(atom id, integer pos)

    sequence children

    children = {}

    -- Is a treeview?
    if ctrl_Type[ id ] = TreeView then
        -- take care of any children
        for i = 1 to length(tvitem_parent) do
            if tvitem_owner[i] = id and tvitem_parent[i] = pos then
                children &= i
                children &= getTVChildren(id, i)
            end if
        end for
    end if
    return children
end function
--END CJT01


Jonas Temple
http://www.yhti.net/~jktemple

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu