::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) {
DeleteChildren (hItem); if (IsDriveNode (hItem))
AddDummyNode (hItem); else
SetButtonState (hItem, strPathName); } }
m_LocalPath = strPathName; *pResult = 0; }
void CLeftView::OnSelchanging(NMHDR* pNMHDR, LRESULT* pResult) {
NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR; // TODO: Add your control notification handler code here HTREEITEM hItem = pNMTreeView->itemNew.hItem; CString strPathName = GetPathFromItem (hItem); *pResult = FALSE;
if(strPathName == MYCOMPUTER) return;
CWaitCursor wait;
if (!AddDirectoryNodes (hItem, strPathName))
*pResult = TRUE;
m_LocalPath = strPathName; *pResult = 0; }
////////////////// DriveExplorerView.h : interface of the CDriveExplorerView class
#if !defined(AFX_DRIVEEXPLORERVIEW_H__29F66873_4E46_11D6_9693_B383368EF622__INCLUDED_) #define
AFX_DRIVEEXPLORERVIEW_H__29F66873_4E46_11D6_9693_B383368EF622__INCLUDED_ #if _MSC_VER > 1000 #pragma once
#endif // _MSC_VER > 1000
class CDriveExplorerView : public CListView {
protected: // create from serialization only CDriveExplorerView();
DECLARE_DYNCREATE(CDriveExplorerView)
// Attributes
public:
CDriveExplorerDoc* GetDocument(); CImageList* m_pImageList; CImageList* m_pImageListL;
// Operations public:
// Overrides
// ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CDriveExplorerView) public:
virtual void OnDraw(CDC* pDC); // overridden to draw this view virtual BOOL PreCreateWindow(CREATESTRUCT& cs); protected:
virtual void OnInitialUpdate(); // called first time after construct virtual BOOL OnPreparePrinting(CPrintInfo* pInfo); virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo); virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo); //}}AFX_VIRTUAL // Implementation public:
void SetupImages(CImageList* mImageList, int iSize); UINT GetListViewIcon(CString s); CString GetFileType(CString s); LPTSTR GetNTS(CString cString);
void AddToListView(WIN32_FIND_DATA* fd); void DeleteAllItems(); virtual ~CDriveExplorerView(); #ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const; #endif
protected:
// Generated message map functions protected:
//{{AFX_MSG(CDriveExplorerView) afx_msg void OnDestroy();
afx_msg void OnSize(UINT nType, int cx, int cy); //}}AFX_MSG
afx_msg void OnStyleChanged(int nStyleType, LPSTYLESTRUCT lpStyleStruct); DECLARE_MESSAGE_MAP()
};
#ifndef _DEBUG // debug version in DriveExplorerView.cpp inline CDriveExplorerDoc* CDriveExplorerView::GetDocument()
{ return (CDriveExplorerDoc*)m_pDocument; }
#endif #endif
///////////////////// DriveExplorerView.cpp : implementation of the CDriveExplorerView class #include \
#include \#include \#include \#ifdef _DEBUG
#define new DEBUG_NEW #undef THIS_FILE
static char THIS_FILE[] = __FILE__; #endif
#define ICI_ACCESSFILE 0 #define ICI_C_SOURCE 1 #define ICI_CDDRV 2 #define ICI_CLSDFLD 3 #define ICI_CURSORFILE 4 #define ICI_DRIVE 5
#define ICI_DRIVERSFILE 6 #define ICI_ERROR 7 #define ICI_EXCELFILE 8 #define ICI_EXCLAMATION 9 #define ICI_EXEFILE 10 #define ICI_FLOPPYDRV 11 #define ICI_FONTFILE 12 #define ICI_FOXPROFILE 13 #define ICI_GENERALFILE 14 #define ICI_HEADERFILE 15 #define ICI_HELPFILE 16 #define ICI_HTMLDOC 17 #define ICI_HTMLHELP 18 #define ICI_IMAGEFILE 19 #define ICI_INFO 20
#define ICI_JAVABEAN 21 #define ICI_JAVACLASSES 22 #define ICI_JAVASOURCE 23 #define ICI_MYCOMPUTER 24 #define ICI_OPENFLD 25 #define ICI_PDFFILE 26 #define ICI_QUESTION 27 #define ICI_REGISTRYFILE 28 #define ICI_SETUPFILE 29
#define ICI_SOUNDFILE 30 #define ICI_TEXTFILE 31 #define ICI_TRASHFILE 32 #define ICI_UNINSTALLFILE 33 #define ICI_VIDEOFILE 34 #define ICI_WINDOWSFILE 35 #define ICI_WORDDOC 36 #define ICI_ZIPFILE 37 #define ICI_CDUP 38
///////////////////////////////////////////////////////////// CDriveExplorerView IMPLEMENT_DYNCREATE(CDriveExplorerView, CListView) BEGIN_MESSAGE_MAP(CDriveExplorerView, CListView) //{{AFX_MSG_MAP(CDriveExplorerView) ON_WM_DESTROY() ON_WM_SIZE() //}}AFX_MSG_MAP END_MESSAGE_MAP()
CDriveExplorerView::CDriveExplorerView() {
// TODO: add construction code here }
CDriveExplorerView::~CDriveExplorerView() { }
BOOL CDriveExplorerView::PreCreateWindow(CREATESTRUCT& cs) {
// TODO: Modify the Window class or styles here by modifying // the CREATESTRUCT cs
cs.style |= LVS_REPORT;
return CListView::PreCreateWindow(cs); }
void CDriveExplorerView::OnDraw(CDC* pDC) {
CDriveExplorerDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc);
CListCtrl& refCtrl = GetListCtrl();
refCtrl.InsertItem(0, \
// TODO: add draw code for native data here }