MOVABLE:
hItem = GetTreeCtrl().InsertItem(strDrive, ILI_FLOPPYDRV, ILI_FLOPPYDRV, hParent);
AddDummyNode(hItem);
break;
case DRIVE_FIXED:
hItem = GetTreeCtrl().InsertItem(strDrive, ILI_DRIVE, ILI_DRIVE, hParent);
AddDummyNode(hItem);
break;
case DRIVE_REMOTE:
hItem = GetTreeCtrl().InsertItem(strDrive, ILI_DRIVE, ILI_DRIVE, hParent);
AddDummyNode(hItem);
break;
case DRIVE_CDROM:
hItem = GetTreeCtrl().InsertItem(strDrive, ILI_CDDRV, ILI_CDDRV, hParent);
AddDummyNode(hItem);
break;
case DRIVE_RAMDISK:
hItem = GetTreeCtrl().InsertItem(strDrive, ILI_CDDRV, ILI_CDDRV, hParent);
AddDummyNode(hItem);
break;
default:
return FALSE;
}
return true;
}
void CLeftView::OnDestroy()
{
CTreeView::OnDestroy();
// TODO: Add your message handler code here
if(m_pImageList != NULL)
m_pImageList = NULL;
delete m_pImageList;
}
void CLeftView::AddDummyNode(HTREEITEM hItem)
{
GetTreeCtrl().InsertItem ("", 0, 0, hItem);
}
CString CLeftView::GetPathFromItem(HTREEITEM hItem)
{
CString strPathName;
while (hItem != NULL)
{
CString string = GetTreeCtrl().GetItemText (hItem);
if ((string.Right (1) != "") && !strPathName.IsEmpty ())
string += "";
strPathName = string + strPathName;
hItem = GetTreeCtrl().GetParentItem (hItem);
}
if(strPathName.Left(11) == MYCOMPUTER && strPathName.GetLength() > 11)
strPathName = strPathName.Mid(12);
return strPathName;
}
BOOL CLeftView::IsPathValid(CString &strPathName)
{
if (strPathName.GetLength () == 3)
return TRUE;
HANDLE hFind;
WIN32_FIND_DATA fd;
BOOL bResult = FALSE;
if ((hFind = ::FindFirstFile ((LPCTSTR) strPathName, &fd)) !=INVALID_HANDLE_VALUE) {
if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
bResult = TRUE;
::CloseHandle (hFind);
}
return bResult;
}
BOOL CLeftView::IsMediaValid(CString &strPathName)
{
// Return TRUE if the drive doesn''''t support removable media.
UINT nDriveType = GetDriveType ((LPCTSTR) strPathName);
if ((nDriveType != DRIVE_REMOVABLE) && (nDriveType != DRIVE_CDROM))
return TRUE;
}
HTREEITEM CLeftView::GetDriveNode(HTREEITEM hItem)
{
HTREEITEM hParent;
do {
hParent = GetTreeCtrl().GetParentItem (hItem);
if (hParent != NULL)
hItem = hParent;
} while (hParent != NULL);
return hItem;
}
UINT CLeftView::DeleteChildren(HTREEITEM hItem)
{
UINT nCount = 0;
HTREEITEM hChild = GetTreeCtrl().GetChildItem (hItem);
while (hChild != NULL) {
HTREEITEM hNextItem = GetTreeCtrl().GetNextSiblingItem (hChild);
GetTreeCtrl().DeleteItem (hChild);
hChild = hNextItem;
nCount++;
}
return nCount;
}
UINT CLeftView::AddDirectoryNodes(HTREEITEM hItem, CString &strPathName)
{
HANDLE hFind;
WIN32_FIND_DATA fd;
UINT nCount = 0;
CString strFileSpec = strPathName;
if (strFileSpec.Right (1) != "")
strFileSpec += "";
strFileSpec += "*.*";
if ((hFind = ::FindFirstFi