|
|
|
|
Forum
Please
Log In
to post a new message or reply to an existing one. If you are not registered, please
register.
NOTE: Some forums may be read-only if you are not currently subscribed to
our technical support services.
Subject |
Author |
Date |
|
Rado Manzela
|
Aug 6, 2009 - 1:20 PM
|
I need to iterate over visible items in the tree grid. This is start of my loop: for (item=ItemGetNext(ItemGetRoot(),false,false,false);item;)
Since ItemGetFirstChild() does not have parameter selecting visible items only, I’ve used ItemGetNext, but it returns hidden item, even when no item is visible. Can you check it please? Thank you.
|
|
Technical Support
|
Aug 10, 2009 - 6:18 AM
|
The following methods of the CExtTreeGridWnd class were designed for enumerating all tree items at any level without checking their visibility:
virtual LONG ItemGetChildCount( HTREEITEM hTreeItem ) const;
virtual HTREEITEM ItemGetChildAt( HTREEITEM hTreeItem, LONG nPos ) const;
virtual HTREEITEM ItemGetFirstSibling( HTREEITEM hTreeItem ) const;
virtual HTREEITEM ItemGetLastSibling( HTREEITEM hTreeItem ) const;
virtual HTREEITEM ItemGetFirstChild( HTREEITEM hTreeItem ) const;
virtual HTREEITEM ItemGetLastChild( HTREEITEM hTreeItem ) const;
You can use these methods and invoke the CExtTreeGridWnd::ItemIsHidden() method for skipping hidden tree items. Please provide us with more details about how we should test the CExtTreeGridWnd::ItemGetNext() method. How many items should be inserted into the tree grid? Which items should we hide? Which should be used as the enumeration start point?
|
|
Rado Manzela
|
Aug 10, 2009 - 11:42 AM
|
I’ve tried it with 2 items, each has 1 child.
Then this code shows 1st item although all items are hidden: HTREEITEM iit = ItemGetFirstChild(ItemGetRoot());
for (; iit != NULL; iit = ItemGetNext(iit,true,false,true))
{
ItemHide(iit,true,true);
// ItemHide(iit,false,true);
}
iit=ItemGetNext(ItemGetRoot(),false,false,false);
if (iit)
{
CExtGridCell *c = ItemGetCell(iit,0);
CString tmp;
c->TextGet(tmp);
AfxMessageBox(tmp);
}
|
|
Technical Support
|
Aug 11, 2009 - 12:27 PM
|
Thank you for reporting this issue. To fix it, please update the source code for the following method:
CExtTreeGridCellNode * CExtTreeGridCellNode::TreeNodeGetNext(
bool bSiblingOnly,
bool bExpandedWalk,
bool bIncludeHidden
)
{
ASSERT_VALID( this );
if( bSiblingOnly )
{
if( m_pNodeNext == NULL )
return NULL;
ASSERT_VALID( m_pNodeNext );
if( bIncludeHidden )
return m_pNodeNext;
CExtTreeGridCellNode * pNode = m_pNodeNext;
for( ; pNode != NULL; pNode = pNode->m_pNodeNext )
{
ASSERT_VALID( pNode );
if( ! pNode->TreeNodeHiddenGet() )
return pNode;
}
return NULL;
} // if( bSiblingOnly )
if( TreeNodeGetChildCount() > 0
&& ( ( ! bExpandedWalk )
|| TreeNodeIsExpanded()
)
)
{
CExtTreeGridCellNode * pNode = TreeNodeGetChildAt( 0 );
if( bIncludeHidden )
return pNode;
for( ; pNode != NULL; pNode = pNode->m_pNodeNext )
{
ASSERT_VALID( pNode );
if( ! pNode->TreeNodeHiddenGet() )
return pNode;
}
return NULL;
}
CExtTreeGridCellNode * pNode = TreeNodeGetNext( true, false, bIncludeHidden );
if( pNode != NULL )
{
ASSERT_VALID( pNode );
return pNode;
}
pNode = this;
CExtTreeGridCellNode * pNodeParent = pNode->TreeNodeGetParent();
for( ; pNodeParent != NULL; )
{
ULONG nSiblingIndex = pNode->TreeNodeGetSiblingIndex();
ULONG nSiblingCount = pNodeParent->TreeNodeGetChildCount();
ASSERT( nSiblingIndex < nSiblingCount );
if( nSiblingIndex < (nSiblingCount-1) )
{
CExtTreeGridCellNode * pNodeTestNext = pNodeParent->TreeNodeGetChildAt( nSiblingIndex + 1 );
ASSERT_VALID( pNodeTestNext );
if( bIncludeHidden
|| ( ! pNodeTestNext->TreeNodeHiddenGet() )
)
{
if( ( ! bExpandedWalk )
|| pNodeParent->TreeNodeIsExpanded()
)
return pNodeTestNext;
}
return pNodeTestNext->TreeNodeGetNext( false, false, bIncludeHidden );
}
pNode = pNodeParent;
pNodeParent = pNodeParent->TreeNodeGetParent();
}
return NULL;
}
|
|