le ((LPCTSTR) strFileSpec, &fd)) ==INVALID_HANDLE_VALUE)
{
if (IsDriveNode (hItem))
AddDummyNode (hItem);
return 0;
}
CWaitCursor wait;
CDriveExplorerDoc* pDoc = GetDocument();
pDoc->m_ExplorerView->DeleteAllItems();
do {
if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{
CString strFileName = (LPCTSTR) &fd.cFileName;
if ((strFileName != ".") && (strFileName != "..")&& (fd.dwFileAttributes != 22))
{
HTREEITEM hChild =GetTreeCtrl().InsertItem ((LPCTSTR) &fd.cFileName,ILI_CLSDFLD , ILI_OPENFLD , hItem , TVI_SORT);
CString strNewPathName = strPathName;
if (strNewPathName.Right (1) != "")
strNewPathName += "";
strNewPathName += (LPCTSTR) &fd.cFileName;
SetButtonState (hChild, strNewPathName);
nCount++;
}
}
else
{
pDoc->m_ExplorerView->AddToListView(&fd);
}
} while (::FindNextFile (hFind, &fd));
::FindClose (hFind);
return nCount;
}
void CLeftView::SetButtonState(HTREEITEM hItem, CString &strPathName)
{
if (HasSubdirectory (strPathName))
AddDummyNode (hItem);
}
BOOL CLeftView::HasSubdirectory(CString &strPathName)
{
HANDLE hFind;
WIN32_FIND_DATA fd;
BOOL bResult = FALSE;
CString strFileSpec = strPathName;
if (strFileSpec.Right (1) != "")
strFileSpec += "";
strFileSpec += "*.*";
if ((hFind = ::FindFirstFile ((LPCTSTR) strFileSpec, &fd)) !=INVALID_HANDLE_VALUE)
{
do {
if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{
CString strFileName = (LPCTSTR) &fd.cFileName;
if ((strFileName != ".") && (strFileName != ".."))
bResult = TRUE;
}
} while (::FindNextFile (hFind, &fd) && !bResult);
::FindClose (hFind);
}
return bResult;
}
BOOL CLeftView::IsDriveNode(HTREEITEM hItem)
{
return (GetTreeCtrl().GetParentItem (hItem) == NULL) ? TRUE : FALSE;
}
void CLeftView::OnItemexpanding(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
HTREEITEM hItem = pNMTreeView->itemNew.hItem;
CString strPathName = GetPathFromItem (hItem);
if (!IsMediaValid (strPathName))
{
HTREEITEM hRoot = GetDriveNode (hItem);
GetTreeCtrl().Expand (hRoot, TVE_COLLAPSE);
DeleteChildren (hRoot);
AddDummyNode (hRoot);
*pResult = TRUE;
return;
}
// Delete the item if strPathName no longer specifies a valid path.
if (!IsPathValid (strPathName))
{
if(strPathName != MYCOMPUTER && strPathName != "")
{
GetTreeCtrl().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)
{
DeleteChi