void CDriveView::OnInitialUpdate() { CTreeView::OnInitialUpdate(); // // Initialize the image list. // m_ilDrives.Create (IDB_DRIVEIMAGES, 16, 1, RGB (255, 0, 255)); GetTreeCtrl ().SetImageList (&m_ilDrives, TVSIL_NORMAL); // // Populate the tree view with drive items. // AddDrives (); // // Show the folders on the current drive. // TCHAR szPath[MAX_PATH]; ::GetCurrentDirectory (sizeof (szPath) / sizeof (TCHAR), szPath); CString strPath = szPath; strPath = strPath.Left (3); HTREEITEM hItem = GetTreeCtrl ().GetNextItem (NULL, TVGN_ROOT); while (hItem != NULL) { if (GetTreeCtrl ().GetItemText (hItem) == strPath) break; hItem = GetTreeCtrl ().GetNextSiblingItem (hItem); } if (hItem != NULL) { GetTreeCtrl ().Expand (hItem, TVE_EXPAND); GetTreeCtrl ().Select (hItem, TVGN_CARET); } }
void CPage6::InitTreeView(HTREEITEM hParent) { int nPos = 0; UINT nCount = 0; CString strDrive = L"?:\\"; DWORD dwDriveList = ::GetLogicalDrives (); CString cTmp; while (dwDriveList) { if (dwDriveList & 1) { cTmp = strDrive; strDrive.SetAt (0, 0x41 + nPos); if (AddDrives(strDrive , hParent)) nCount++; } dwDriveList >>= 1; nPos++; } return; }