void CPage6::OnItemexpanding(NMHDR *pNMHDR, LRESULT *pResult) { LPNMTREEVIEW pNMTreeView = reinterpret_cast<LPNMTREEVIEW>(pNMHDR); HTREEITEM hItem = pNMTreeView->itemNew.hItem; CString strPathName = GetPathFromItem (hItem); if (!IsMediaValid (strPathName)) { HTREEITEM hRoot = GetDriveNode (hItem); m_FileTree.Expand (hRoot, TVE_COLLAPSE); DeleteChildren (hRoot); AddDummyNode (hRoot); *pResult = TRUE; return; } if (!IsPathValid (strPathName)) { if(strPathName != MYCOMPUTER && strPathName != "") { m_FileTree.DeleteItem (hItem); *pResult = TRUE; return; } } CWaitCursor wait; if (pNMTreeView->action == TVE_EXPAND) { if(strPathName != MYCOMPUTER) { DeleteChildren (hItem); if (!AddDirectoryNodes (hItem, strPathName)) *pResult = TRUE; } } else { if(strPathName != MYCOMPUTER) { DeleteChildren (hItem); if (IsDriveNode (hItem)) AddDummyNode (hItem); else SetButtonState (hItem, strPathName); } } m_LocalPath = strPathName; *pResult = 0; }
void FolderTree::DoExpand(HTREEITEM hItem) { FolderTreeItemInfo* pItem = (FolderTreeItemInfo*) GetItemData(hItem); //Reset the drive node if the drive is empty or the media has changed if (IsMediaValid(pItem->m_sFQPath)) { //Delete the item if the path is no longer valid if (IsFolder(pItem->m_sFQPath)) { //Add the new items to the tree if it does not have any child items //already if (!GetChildItem(hItem)) DisplayPath(pItem->m_sFQPath, hItem); } else if (hItem == m_hMyComputerRoot) { //Display an hour glass as this may take some time //CWaitCursor wait; //Enumerate the local drive letters auto shared = sp->getViewItems(sp->curProfile); DisplayDrives(m_hMyComputerRoot, FALSE, shared); } else if ((hItem == m_hNetworkRoot) || (pItem->m_pNetResource)) { //Display an hour glass as this may take some time //CWaitCursor wait; //Enumerate the network resources EnumNetwork(hItem); } else { //Before we delete it see if we are the only child item HTREEITEM hParent = GetParentItem(hItem); //Delete the item DeleteItem(hItem); //Remove all the child items from the parent SetHasPlusButton(hParent, false); } } else { //Display an hour glass as this may take some time //CWaitCursor wait; //Collapse the drive node and remove all the child items from it Expand(hItem, TVE_COLLAPSE); DeleteChildren(hItem, true); } }