/*
================
CPathTreeCtrl::FindItem

Find the given path in the tree.
================
*/
HTREEITEM CPathTreeCtrl::FindItem( const idStr &pathName ) {
	int lastSlash;
	idStr path, tmpPath, itemName;
	HTREEITEM item, parentItem;

	parentItem = NULL;
	item = GetRootItem();

	lastSlash = pathName.Last( '/' );

	while( item && lastSlash > path.Length() ) {
		itemName = GetItemText( item );
		tmpPath = path + itemName;
		if ( pathName.Icmpn( tmpPath, tmpPath.Length() ) == 0 ) {
			parentItem = item;
			item = GetChildItem( item );
			path = tmpPath + "/";
		} else {
			item = GetNextSiblingItem( item );
		}
	}

	for ( item = GetChildItem( parentItem ); item; item = GetNextSiblingItem( item ) ) {
		itemName = GetItemText( item );
		if ( pathName.Icmp( path + itemName ) == 0 ) {
			return item;
		}
	}

	return NULL;
}
void CDirectoryTreeCtrl::OnTvnItemexpanding(NMHDR *pNMHDR, LRESULT *pResult)
{
	CWaitCursor curWait;
	SetRedraw(FALSE);

	LPNMTREEVIEW pNMTreeView = reinterpret_cast<LPNMTREEVIEW>(pNMHDR);
	HTREEITEM hItem = pNMTreeView->itemNew.hItem;
	// remove all subitems
	HTREEITEM hRemove = GetChildItem(hItem);
	while(hRemove)
	{
		DeleteItem(hRemove);
		hRemove = GetChildItem(hItem);
	}

	// get the directory
	CString strDir = GetFullPath(hItem);

	// fetch all subdirectories and add them to the node
	AddSubdirectories(hItem, strDir);

	SetRedraw(TRUE);
	Invalidate();
	*pResult = 0;
}
/* #FN#
   Pushes down and selects an item one level at a time until either we
   can't find anymore parts of the path, or we've finished searching

   Doesn't work on network (UNC) paths (Could search NETHOOD when
   prefix is \\) */
void
/* #AS#
   Nothing */
CShellTree::
TunnelTree(
	LPCSTR lpszPath /* #IN# */
)
{
	char szSearchPath[ MAX_PATH + 1 ];
	BOOL bFound = FALSE;
	int  i = 0;

	HTREEITEM hTopLevelItem;
	HTREEITEM hItem;

	if( (hTopLevelItem = GetRootItem()) )
	{
		do /* Enumerate the top level items */
		{
			if( Expand( hTopLevelItem, TVE_EXPAND ) )
			{
				hItem = GetChildItem( hTopLevelItem );

				while( hItem )
				{
					for( ; i < (int)strlen( lpszPath ) && lpszPath[ i ] != '\\'; i++ )
						szSearchPath[ i ] = lpszPath[ i ];

					szSearchPath[ i++ ] = '\0';
					/* Add ending backslash to drive name */
					if( strlen( szSearchPath ) == 2 && szSearchPath[ 1 ] == ':' )
						strcat( szSearchPath, "\\" );

					if( SearchTree( hItem, szSearchPath ) )
					{
						hItem = GetSelectedItem();
						if( Expand( hItem, TVE_EXPAND ) )
						{
							/* Get first leaf of the new bunch */
							hItem = GetChildItem( hItem );
						}
						bFound = TRUE;
					}
					else
						break;
					/* Append a folder delimiter */
					szSearchPath[ i - 1 ] = '\\';
				}
				/* The path has not been found, reset the searching "engine" */
				if( !bFound )
				{
					Expand( hTopLevelItem, TVE_COLLAPSE );
					i = 0;
				}
			}
		}
		while( !bFound && (hTopLevelItem = GetNextSiblingItem( hTopLevelItem )) );
	}
} /* #OF# CShellTree::TunnelTree */
Example #4
0
void CCJShellTree::TunnelTree(CString strFindPath)
{
	HTREEITEM subNode = GetRootItem();
	CString szPathHop;
	char drive[_MAX_DRIVE];
	char dir[_MAX_DIR];
	char fname[_MAX_FNAME];
	char ext[_MAX_EXT];
	char delimiter[]="\\";

	m_bRefresh = false;
	
	if(!m_shell.Exist(strFindPath))
	{
		if (strFindPath.GetLength() == 3)
		{
		}

		else
		{
			MessageBox(strFindPath,_T("Folder not found"),MB_ICONERROR);
			return;
		}
	}
	
	if(strFindPath.ReverseFind(_T('\\')) != strFindPath.GetLength()-1)
	{
		strFindPath += _T("\\");
	}
	
	m_shell.SplitPath(strFindPath,drive,dir,fname,ext);
	
	//search the drive first
	szPathHop=drive;
	subNode=GetChildItem(subNode);

	if(subNode)
	{
		if(SearchTree(subNode,szPathHop, CCJShellTree::type_drive))
		{
			SetRedraw(FALSE);
			//break down subfolders and search
			char *p=strtok(dir,delimiter);
			while(p)
			{
				subNode = GetSelectedItem();
				Expand(subNode, TVE_EXPAND);
				subNode = GetChildItem(subNode);

				if(SearchTree(subNode,p,CCJShellTree::type_folder))
					p=strtok(NULL,delimiter);
				else
					p=NULL;
			}
			SetRedraw();
		}
	}
}
Example #5
0
	//******************************************
	//	删除一个结点分枝,如果该结点的父结点没有其它子节点则一起删除
	//******************************************
	BOOL DeleteItemEx(HSTREEITEM hItem)
	{
		if(GetChildItem(hItem)) return FALSE;
		while(hItem && !GetChildItem(hItem))
		{
			HSTREEITEM hParent=GetParentItem(hItem);
			DeleteItem(hItem);
			hItem=hParent;
		}
		return TRUE;
	}
Example #6
0
BOOL CTreeCtrlEx::OnItemexpanding(NMHDR* pNMHDR, LRESULT* pResult) 
{
	NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;

	if ( pNMTreeView->action == TVE_COLLAPSE )
	{
		HTREEITEM hItem = GetChildItem( pNMTreeView->itemNew.hItem );

		while ( hItem )
		{
			if ( GetItemState( hItem, TVIS_SELECTED ) & TVIS_SELECTED )
				SetItemState( hItem, 0, TVIS_SELECTED );

			// Get the next node: First see if current node has a child
			HTREEITEM hNextItem = GetChildItem( hItem );
			if ( !hNextItem )
			{
				// No child: Get next sibling item
				if ( !( hNextItem = GetNextSiblingItem( hItem ) ) )
				{
					HTREEITEM hParentItem = hItem;
					while ( !hNextItem )
					{
						// No more children: Get parent
						if ( !( hParentItem = GetParentItem( hParentItem ) ) )
							break;

						// Quit when parent is the collapsed node
						// (Don't do anything to siblings of this)
						if ( hParentItem == pNMTreeView->itemNew.hItem )
							break;

						// Get next sibling to parent
						hNextItem = GetNextSiblingItem( hParentItem );
					}

					// Quit when parent is the collapsed node
					if ( hParentItem == pNMTreeView->itemNew.hItem )
						break;
				}
			}

			hItem = hNextItem;
		}
	}
	

	if (m_Parent)
		m_Parent->SendMessage(MB_TV_MSG, (WPARAM) pNMHDR, (LPARAM)pResult);

	*pResult = 0;
	return FALSE;	// Allow parent to handle this notification as well
}
Example #7
0
void CModelMacro::ChangeToIOAnalogData()
{
	beginResetModel();

	if (rootItem)
	{
		rootItem->ClearChildren();
	}

	GetChildItem(rootItem, CGrammarManagerFactory::STR_MACRO_AIN);
	GetChildItem(rootItem, CGrammarManagerFactory::STR_MACRO_AOUT);

	endResetModel();
}
Example #8
0
void CModelMacro::ChangeToSystemPragramData()
{
	beginResetModel();

	if (rootItem)
	{
		rootItem->ClearChildren();
	}

	GetChildItem(rootItem, CGrammarManagerFactory::STR_MACRO_ABORT);
	GetChildItem(rootItem, CGrammarManagerFactory::STR_MACRO_END);

	endResetModel();
}
Example #9
0
void CModelMacro::ChangeToSystemOthersData()
{
	beginResetModel();

	if (rootItem)
	{
		rootItem->ClearChildren();
	}

	GetChildItem(rootItem, CGrammarManagerFactory::STR_MACRO_SET_TOOLFRAME);
	GetChildItem(rootItem, CGrammarManagerFactory::STR_MACRO_SET_USERFRAME);

	endResetModel();
}
Example #10
0
void CModelMacro::ChangeToWeldSpotData()
{
	beginResetModel();

	if (rootItem)
	{
		rootItem->ClearChildren();
	}

	GetChildItem(rootItem, CGrammarManagerFactory::STR_MACRO_SPOT_ON);
	GetChildItem(rootItem, CGrammarManagerFactory::STR_MACRO_SPOT_OFF);
	GetChildItem(rootItem, CGrammarManagerFactory::STR_MACRO_SET_SPOT);

	endResetModel();
}
Example #11
0
void CCheckBoxTree::vSetCheckParent(HTREEITEM hItem)
{
    if(hItem == nullptr)
    {
        return;
    }

    HTREEITEM hParentItem = GetParentItem(hItem);
    HTREEITEM hChildItem;
    BOOL bAllChecked = TRUE;
    if( ItemHasChildren(hParentItem))
    {
        hChildItem = GetChildItem(hParentItem);
        while(hChildItem)
        {
            if(!bIsItemChecked(hChildItem))
            {
                bAllChecked = FALSE;
                break;
            }
            hChildItem = GetNextSiblingItem(hChildItem);
        }
    }
    BOOL fCheck=0;
    vSetCheck(hParentItem, bAllChecked);
    vSetCheckParent(hParentItem);
    vSetCheckChildren(hParentItem,!fCheck);
}
Example #12
0
void CLibraryFolderCtrl::Update(DWORD nUpdateCookie)
{
	CList< CLibraryFolder* > pAlready;

	for ( HTREEITEM hItem = GetChildItem( m_hRoot ) ; hItem ; )
	{
		HTREEITEM hNext = GetNextSiblingItem( hItem );

		CLibraryFolder* pFolder = (CLibraryFolder*)GetItemData( hItem );

		if ( LibraryFolders.CheckFolder( pFolder ) )
		{
			Update( pFolder, hItem, NULL, nUpdateCookie, FALSE );
			pAlready.AddTail( pFolder );
		}
		else
		{
			DeleteItem( hItem );
		}

		hItem = hNext;
	}

	for ( POSITION pos = LibraryFolders.GetFolderIterator() ; pos ; )
	{
		CLibraryFolder* pFolder = LibraryFolders.GetNextFolder( pos );

		if ( pAlready.Find( pFolder ) == NULL )
		{
			Update( pFolder, NULL, m_hRoot, nUpdateCookie, FALSE );
		}
	}
}
std::vector<CTest*> CTestSelectionTree::getSelectedTests()
{
	std::vector<CTest*> selectedTestsVect;

	HTREEITEM hCurrent = GetChildItem(hRoot);
	while (hCurrent != NULL) 
	{
		
		bool bChecked=GetCheck(hCurrent);

		if(bChecked)
		{
/*
			AfxMessageBox(_T("Item checked =")+GetItemText(hCurrent));
*/
			CTest* pTest=(CTest*) GetItemData(hCurrent);
			selectedTestsVect.push_back(pTest);
		}
		

		// Try to get the next item
		hCurrent = GetNextItem(hCurrent, TVGN_NEXT);
		//
	}
	return selectedTestsVect;
}
/*
EBaseItem* EXTreeCtrl::GetBaseItem(HTREEITEM hTi)
{
	if(!hTi)
	{
		// First see if an item is active
		if(m_hActiveItem)
		{
			hTi = m_hActiveItem;
			SelectItem(hTi);
			m_hActiveItem = 0;
		}
		else
		{
			if(m_bContextMenuActivated)
			{
				hTi = GetRootItem();
			}
			else
			{
				// Try to get active item
				hTi = GetSelectedItem();
			}
		}

		if(!hTi)
		{
			hTi = GetRootItem();
		}
	}

	if(hTi)
	{
		return reinterpret_cast < EBaseItem * > (GetItemData(hTi));
	}
	return NULL;
}
*/
void EXTreeCtrl::ExpandTree(HTREEITEM hItem,bool bIncludeSub)
{
    if(hItem == NULL)
        hItem = GetRootItem();

    if(hItem)
    {
        Expand(hItem,TVE_EXPAND);

        if(bIncludeSub)
        {
            HTREEITEM ChildItem = GetChildItem(hItem);
            while(ChildItem != NULL)
            {
                Expand(ChildItem,TVE_EXPAND);
                ExpandTree(ChildItem,true);
                ChildItem = GetNextItem(ChildItem,TVGN_NEXT);
            }
        }
    }

    /*
    	if(hItem == NULL)
    		return;

    	Expand(hItem,TVE_EXPAND);
    	HTREEITEM ChildItem = GetChildItem(hItem);
    	do
    	{
    		Expand(ChildItem,TVE_TOGGLE);
    	}
    	while( (ChildItem = GetNextSiblingItem( ChildItem )) != NULL );
    */
}
//-----------------------------------------------------------------------------
// Purpose: Returns the tree item in the given subtree associated with the given
//			visgroup, NULL if none.
//-----------------------------------------------------------------------------
HTREEITEM CGroupList::FindVisGroupItemRecursive(HTREEITEM hItem, CVisGroup *pVisGroup)
{
    if (hItem)
    {
        CVisGroup *pVisGroupCheck = (CVisGroup *)GetItemData(hItem);
        if (pVisGroupCheck == pVisGroup)
        {
            return hItem;
        }

        if (ItemHasChildren(hItem))
        {
            HTREEITEM hChildItem = GetChildItem(hItem);
            while (hChildItem != NULL)
            {
                HTREEITEM hFoundItem = FindVisGroupItemRecursive(hChildItem, pVisGroup);
                if (hFoundItem)
                {
                    return hFoundItem;
                }

                hChildItem = GetNextItem(hChildItem, TVGN_NEXT);
            }
        }
    }

    return NULL;
}
Example #16
0
HTREEITEM CMyTreeCtrl::FindItem( HTREEITEM hItem, DWORD dwData, bool f )
{
	if( hItem == (HTREEITEM)NULL )
		return (HTREEITEM)NULL;

	PSrvrData pSrvrData	= (PSrvrData)GetItemData( hItem );
	if( f == true ) {
		if( pSrvrData->dwId == dwData )
			return hItem;
	}
	else {
		if( pSrvrData->dpid == dwData )
			return hItem;
	}

	if( TRUE == ItemHasChildren( hItem ) )
	{
		HTREEITEM hFind		= FindItem( GetChildItem( hItem ), dwData, f );
		if( hFind != (HTREEITEM)NULL )
			return hFind;
		return FindItem( GetNextSiblingItem( hItem ), dwData, f );
	}
	else
	{
		return FindItem( GetNextSiblingItem( hItem ), dwData, f );
	}
}
Example #17
0
void CMyTreeCtrl::EnumItem( HTREEITEM hItem, bool f )
{
	if( hItem == (HTREEITEM)NULL )
		return;

	if( f == true ) {
		m_uSizeofEnumItem	= 0;
		m_uIndexofEnumItem	= 0;
	}

	PSrvrData pData		= (PSrvrData)GetItemData( hItem );
	ASSERT( pData );
	if( pData->dwId < MAX_ID )
		m_ahEnumItem[m_uSizeofEnumItem++]	= hItem;

	if( TRUE == ItemHasChildren( hItem ) )
	{
		if( f == false )
			EnumItem( GetNextSiblingItem( hItem ), false );
		EnumItem( GetChildItem( hItem ), false );
	}
	else
	{
		if( f == false )
			EnumItem( GetNextSiblingItem( hItem ), false );
	}
}
Example #18
0
void CMyTreeCtrl::PostEnumItem( HTREEITEM hItem, bool f, PENUMITEM pEnumItem )
{
	if( hItem == (HTREEITEM)NULL )
		return;

	if( f == true )
		pEnumItem	= new ENUMITEM;

	PSrvrData pData		= (PSrvrData)GetItemData( hItem );
	ASSERT( pData );
	if( pData->dwId < MAX_ID )
		pEnumItem->m_ahEnumItem[pEnumItem->m_uSizeofEnumItem++]		= hItem;

	if( TRUE == ItemHasChildren( hItem ) )
	{
		if( f == false )
			PostEnumItem( GetNextSiblingItem( hItem ), false, pEnumItem );
		PostEnumItem( GetChildItem( hItem ), false, pEnumItem );
	}
	else
	{
		if( f == false )
			PostEnumItem( GetNextSiblingItem( hItem ), false, pEnumItem );
	}

	if( f == true )
	{
		m_lspEnumItem.push_back( pEnumItem );
	}
}
Example #19
0
HTREEITEM CSelectObjectPropTree::FindItem (HTREEITEM hItem, LPCSTR pcItem)
{
	if (NULL == hItem) return NULL;

// wenn's das RootItem ist, dann erstes Child geben lassen
HTREEITEM hChildItem = NULL;

	if (TVI_ROOT == hItem)
		hChildItem = GetNextItem (NULL, TVGN_CHILD);
	else {
	// zuerst dieses Item testen (die Root kann's nicht sein)
	string strItem = GetItemText (hItem);

		if (strItem == pcItem)
			return hItem;

		hChildItem = GetChildItem (hItem);
	}

// anschließen alle Childs abtesten
	while (NULL != hChildItem) {
	HTREEITEM hReturn = FindItem (hChildItem, pcItem);

		if (NULL != hReturn)
			return hReturn;
		hChildItem = GetNextItem (hChildItem, TVGN_NEXT);
	}
	return NULL;	// nichts gefunden
}
Example #20
0
// Recursively sort the entire tree
void CMultiSelTreeCtrl::SortTree(HTREEITEM topNode/*=NULL*/, HTREEITEM parentNode/*=NULL*/)
{
	HTREEITEM item;

	// Sort things at the this level
	if (parentNode && (m_SortByExtension || m_SortByResolveStat 
					|| m_SortByAction    || m_SortByFilename))
	{
		TVSORTCB tvsortcb;
		tvsortcb.hParent = topNode;
		tvsortcb.lParam = (m_SortByResolveStat ? 2 : 0) + (m_SortByExtension ? 1 : 0) 
						+ (m_SortByFilename ? 8 : 0)    + (m_SortByAction ? 4 : 0);
		tvsortcb.lpfnCompare = SortTreeCB;
		SortChildrenCB(&tvsortcb);
	}
	else 
		SortChildren(topNode);

	// Get the first item at this level
	if(topNode == NULL)
		item=GetNextItem(TVI_ROOT, TVGN_ROOT);
	else
		item=GetChildItem(topNode);   // Get first child

	// Recurse all items that have children
	while(item != NULL)
	{
		if(ItemHasChildren(item))
			SortTree(item, topNode);
		item=GetNextSiblingItem(item);
	}
}
Example #21
0
BOOL CDirTreeCtrl::IsValidPath(LPCTSTR strPath)
{
	// This function check the Pathname
	
	HTREEITEM hChild;
	CString   strItem;
	CString   strTempPath = strPath;
	BOOL      bFound = FALSE;
	CFileFind find;

	hChild = GetChildItem( TVI_ROOT );
	strTempPath.MakeUpper();
	strTempPath.TrimRight('\\');

	while ( hChild )
	{
		strItem = GetItemText( hChild );
		strItem.MakeUpper();
		if ( strItem == strTempPath.Mid( 0, strItem.GetLength() ) )
		{
			bFound = TRUE;
			break;
		}
		hChild = GetNextItem( hChild, TVGN_NEXT );
	}
    
	if ( !bFound )
		return FALSE;

	strTempPath += _T("\\nul");
	if ( find.FindFile( strTempPath ) )
		return TRUE;
     
	return FALSE;
}
Example #22
0
BOOL CMyTreeCtrl::TransferItem(HTREEITEM hitemDrag, HTREEITEM hitemDrop)
{
	TV_INSERTSTRUCT     tvstruct;
	TCHAR               sztBuffer[50];
	HTREEITEM           hNewItem, hFirstChild;

		// avoid an infinite recursion situation
	tvstruct.item.hItem = hitemDrag;
	tvstruct.item.cchTextMax = 49;
	tvstruct.item.pszText = sztBuffer;
	tvstruct.item.mask = TVIF_CHILDREN | TVIF_HANDLE | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_TEXT;
	GetItem(&tvstruct.item);  // get information of the dragged element

	tvstruct.hParent = hitemDrop;
	tvstruct.hInsertAfter = TVI_SORT;
	tvstruct.item.mask = TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_TEXT;
	hNewItem = InsertItem(&tvstruct);

	while ((hFirstChild = GetChildItem(hitemDrag)) != NULL)
	{
		TransferItem(hFirstChild, hNewItem);  // recursively transfer all the items
		DeleteItem(hFirstChild);        // delete the first child and all its children
	}
	return TRUE;
}
/*
================
CPathTreeCtrl::InsertPathIntoTree

Inserts a new item going from the root down the tree only creating paths where necessary.
This is slow and should only be used to insert single items.
================
*/
HTREEITEM CPathTreeCtrl::InsertPathIntoTree( const idStr &pathName, const int id ) {
	int lastSlash;
	idStr path, tmpPath, itemName;
	HTREEITEM item, parentItem;

	parentItem = NULL;
	item = GetRootItem();

	lastSlash = pathName.Last( '/' );

	while( item && lastSlash > path.Length() ) {
		itemName = GetItemText( item );
		tmpPath = path + itemName;
		if ( pathName.Icmpn( tmpPath, tmpPath.Length() ) == 0 ) {
			parentItem = item;
			item = GetChildItem( item );
			path = tmpPath + "/";
		} else {
			item = GetNextSiblingItem( item );
		}
	}

	while( lastSlash > path.Length() ) {
		pathName.Mid( path.Length(), pathName.Length(), tmpPath );
		tmpPath.Left( tmpPath.Find( '/' ), itemName );
		parentItem = InsertItem( itemName, parentItem );
		path += itemName + "/";
	}

	pathName.Mid( path.Length(), pathName.Length(), itemName );
	item = InsertItem( itemName, parentItem, TVI_SORT );
	SetItemData( item, id );

	return item;
}
Example #24
0
	//****************************************************
	//	获取当前结点的下一个结点
	//	HSTREEITEM hItem:当前结点
	//	int &nLevel:当前结点(hItem)与目标结点(return)的层次关系,1-父子关系,0-兄弟关系,-n-子->父的兄弟
	//	return:当前结点的下一个结点
	//	remark:如果当前结点有子结点,则返回自己的第一个子结点,
	//			否则如果有向下的兄弟结点,则返回自己向下兄弟结点、
	//			否则搜索自己的父结点的向下兄弟结点
	//****************************************************
	HSTREEITEM GetNextItem(HSTREEITEM hItem,int &nLevel)
	{
		if(hItem==STVI_ROOT)
		{
			nLevel=1;
			return (HSTREEITEM)m_hRootFirst;
		}

		HSTREEITEM hRet=GetChildItem(hItem);
		if(hRet)
		{
			nLevel=1;
			return hRet;
		}
		HSTREEITEM hParent=hItem;
		nLevel=0;
		while(hParent)
		{
			hRet=GetNextSiblingItem(hParent);
			if(hRet) return hRet;
			nLevel--;
			hParent=GetParentItem(hParent);
		}
		return NULL;
	}
Example #25
0
CString CStatisticsTree::GetText(bool onlyVisible, HTREEITEM theItem, int theItemLevel, bool firstItem)
{
	bool bPrintHeader = firstItem;
	HTREEITEM hCurrent;
	if (theItem == NULL)
	{
		hCurrent = GetRootItem(); // Copy All Vis or Copy All
	}
	else
	{
		if (bPrintHeader && (!ItemHasChildren(theItem) || !IsExpanded(theItem)))
			bPrintHeader = false;
		hCurrent = theItem;
	}

	CString	strBuffer;
	if (bPrintHeader)
		strBuffer.Format(_T("eMule v%s %s [%s]\r\n\r\n"), theApp.m_strCurVersionLong, GetResString(IDS_SF_STATISTICS) ,thePrefs.GetUserNick());

	while (hCurrent != NULL)
	{
		for (int i = 0; i < theItemLevel; i++)
			strBuffer += _T("   ");
		strBuffer += GetItemText(hCurrent);
		if (bPrintHeader || !firstItem)
			strBuffer += _T("\r\n");
		if (ItemHasChildren(hCurrent) && (!onlyVisible || IsExpanded(hCurrent)))
			strBuffer += GetText(onlyVisible, GetChildItem(hCurrent), theItemLevel+1, false);
		hCurrent = GetNextItem(hCurrent, TVGN_NEXT);
		if (firstItem && theItem != NULL)
			break; // Copy Selected Branch was used, so we don't want to copy all branches at this level.  Only the one that was selected.
	}
	return strBuffer;
}
Example #26
0
HTREEITEM CTreeCtrlEx::GetNextItem(HTREEITEM hItem, UINT nCode)
{
	if (nCode==TVGN_EX_ALL)
	{
		// This special code lets us iterate through ALL tree items regardless 
		// of their parent/child relationship (very handy)
		HTREEITEM hNextItem;

		// If it has a child node, this will be the next item
		hNextItem = GetChildItem( hItem );
		if (hNextItem)
			return hNextItem;

		// Otherwise, see if it has a next sibling item
		hNextItem = GetNextSiblingItem(hItem);
		if (hNextItem)
			return hNextItem;

		// Finally, look for next sibling to the parent item
		HTREEITEM hParentItem=hItem;
		while (!hNextItem && hParentItem)
		{
			// No more children: Get next sibling to parent
			hParentItem = GetParentItem(hParentItem);
			hNextItem = GetNextSiblingItem(hParentItem);
		}

		return hNextItem; // will return NULL if no more parents
	}
	else
		return CTreeCtrl::GetNextItem(hItem, nCode);	// standard processing
}
Example #27
0
//寻找树项
HTREEITEM CUserCompanionList::SearchCompanionInfo(HTREEITEM hRootTreeItem, tagCompanionItem * pCompanionInfo)
{
	//获取父项
	if (hRootTreeItem==NULL) hRootTreeItem=m_hItemRoot;
	if (hRootTreeItem==NULL) return NULL;

	//变量定义
	HTREEITEM hTreeItemTemp=NULL;
	DWORD_PTR dwBindParam=(DWORD_PTR)pCompanionInfo;

	//循环查找
	do
	{
		//绑定判断
		if (GetItemData(hRootTreeItem)==dwBindParam) return hRootTreeItem;

		//子项搜索
		hTreeItemTemp=GetChildItem(hRootTreeItem);
		if (hTreeItemTemp!=NULL)
		{
			hTreeItemTemp=SearchCompanionInfo(hTreeItemTemp,pCompanionInfo);
			if (hTreeItemTemp!=NULL) return hTreeItemTemp;
		}

		//下一树项
		hRootTreeItem=GetNextItem(hRootTreeItem,TVGN_NEXT);

	} while (hRootTreeItem!=NULL);

	return NULL;
}
Example #28
0
// This returns a string of 1's and 0's indicating
// which parent items are expanded.  Only saves the
// bold items.
CString CStatisticsTree::GetExpandedMask(HTREEITEM theItem)
{
	HTREEITEM	hCurrent;
	CString		tempMask;

	tempMask.Empty();

	if (theItem == NULL)
		hCurrent = GetRootItem();
	else
		hCurrent = theItem;

	while (hCurrent != NULL)
	{
		if (ItemHasChildren(hCurrent) && IsBold(hCurrent)) {
			if (IsExpanded(hCurrent))
				tempMask += "1";
			if (!IsExpanded(hCurrent))
				tempMask += "0";
			tempMask += GetExpandedMask(GetChildItem(hCurrent));
		}
		hCurrent = GetNextItem(hCurrent, TVGN_NEXT);
	}
	return tempMask;
}
Example #29
0
// Recursively sorts a node and its children using an application
// specific sorting function
void CMyTreeCtrl::SortNodeAndChildren(HTREEITEM hItem, PFNTVCOMPARE lpfnCompare)
{
	// Create the sorting structure
	TVSORTCB sort;
	sort.hParent=hItem;
	sort.lParam=0;
	sort.lpfnCompare=lpfnCompare;

	// Sort the node
	SortChildrenCB(&sort);

	// Determine if this item has children
	if (ItemHasChildren(hItem))
	{
		// Get the first child item
		HTREEITEM hChild=GetChildItem(hItem);

		// Sort the child
		SortNodeAndChildren(hChild, lpfnCompare);

		// Sort the rest of the children
		HTREEITEM hSibling=GetNextSiblingItem(hChild);
		while (hSibling)
		{
			SortNodeAndChildren(hSibling, lpfnCompare);
			hSibling=GetNextSiblingItem(hSibling);
		}
	}
}
Example #30
0
// This takes a string and uses it to set the expanded or
// collapsed state of the tree items.
int CStatisticsTree::ApplyExpandedMask(CString theMask, HTREEITEM theItem, int theStringIndex)
{
	HTREEITEM	hCurrent;

	if (theItem == NULL) {
		hCurrent = GetRootItem();
		SetRedraw(false);
		ExpandAll(true);
		m_bExpandingAll = true;
	}
	else
		hCurrent = theItem;

	while (hCurrent != NULL && theStringIndex < theMask.GetLength())
	{
		if (ItemHasChildren(hCurrent) && IsBold(hCurrent)) {
			if (theMask.GetAt(theStringIndex) == '0') Expand(hCurrent, TVE_COLLAPSE);
			theStringIndex++;
			theStringIndex = ApplyExpandedMask(theMask, GetChildItem(hCurrent), theStringIndex);			
		}
		hCurrent = GetNextItem(hCurrent, TVGN_NEXT);
	}
	if (theItem == NULL) {
		SetRedraw(true);
		m_bExpandingAll = true;
	}
	return theStringIndex;
}