NDING, OnItemexpanding)
ON_NOTIFY_REFLECT(TVN_SELCHANGING, OnSelchanging)
//}}AFX_MSG_MAP
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CTreeView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CTreeView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CTreeView::OnFilePrintPreview)
END_MESSAGE_MAP()
///////////////////////////////////// CLeftView construction/destruction
CLeftView::CLeftView()
{
// TODO: add construction code here
}
CLeftView::~CLeftView()
{}
BOOL CLeftView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying the CREATESTRUCT cs
cs.style |= TVS_HASBUTTONS | TVS_LINESATROOT | TVS_HASLINES;
return CTreeView::PreCreateWindow(cs);
}
void CLeftView::OnDraw(CDC* pDC)
{
CDriveExplorerDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
}
BOOL CLeftView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CLeftView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CLeftView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
void CLeftView::OnInitialUpdate()
{
CTreeView::OnInitialUpdate();
m_pImageList = new CImageList();
CWinApp* pApp = AfxGetApp();
// ASSERT(m_pImageList != NULL); // serious allocation failure checking
m_pImageList->Create(16, 16, ILC_COLOR8 | ILC_MASK, 9, 9);
m_pImageList->Add(pApp->LoadIcon(ICO_CDDRV));
m_pImageList->Add(pApp->LoadIcon(ICO_CLSDFLD));
m_pImageList->Add(pApp->LoadIcon(ICO_DRIVE));
m_pImageList->Add(pApp->LoadIcon(ICO_FLOPPYDRV));
m_pImageList->Add(pApp->LoadIcon(ICO_MYCOMP));
m_pImageList->Add(pApp->LoadIcon(ICO_OPENFLD));
m_pImageList->Add(pApp->LoadIcon(ICO_TEXTFILE));
GetTreeCtrl().SetImageList(m_pImageList , TVSIL_NORMAL);
HTREEITEM hParent = GetTreeCtrl().InsertItem(MYCOMPUTER,
ILI_MYCOMP, ILI_MYCOMP);
InitTreeView(hParent);
GetTreeCtrl().Expand(hParent, TVE_EXPAND);
}
#ifdef _DEBUG
void CLeftView::AssertValid() const
{
CTreeView::AssertValid();
}
void CLeftView::Dump(CDumpContext& dc) const
{
CTreeView::Dump(dc);
}
CDriveExplorerDoc* CLeftView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CDriveExplorerDoc)));
return (CDriveExplorerDoc*)m_pDocument;
}
#endif //_DEBUG
void CLeftView::InitTreeView(HTREEITEM hParent)
{
int nPos = 0;
UINT nCount = 0;
CString strDrive = "?:";
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;
}
BOOL CLeftView::AddDrives(CString strDrive, HTREEITEM hParent)
{
HTREEITEM hItem;
UINT nType = ::GetDriveType ((LPCTSTR) strDrive);
UINT nDrive = (UINT) strDrive[0] - 0x41;
switch (nType) {
case DRIVE_RE