⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 filetreectrl.h

📁 版本更新了一下
💻 H
📖 第 1 页 / 共 2 页
字号:
/*
Module : FileTreeCtrl.h
Purpose: Interface for an MFC class which provides a tree control similiar 
         to the left hand side of explorer

Copyright (c) 1999 - 2001 by PJ Naughter.  (Web: www.naughter.com, Email: pjna@naughter.com)

All rights reserved.

Copyright / Usage Details:

You are allowed to include the source code in any product (commercial, shareware, freeware or otherwise) 
when your product is released in binary form. You are allowed to modify the source code in any way you want 
except you cannot modify the copyright details at the top of each module. If you want to distribute source 
code with your application, then you are only allowed to distribute versions released by the author. This is 
to maintain a single distribution point for the source code. 

*/



////////////////////////////////// Macros / Defines  ///////////////////////

#ifndef __FILETREECTRL_H__
#define __FILETREECTRL_H__



#ifndef __AFXMT_H__
#pragma message("To avoid this message, put afxmt.h in your PCH (normally stdafx.h)")
#include <afxmt.h>
#endif

#ifndef _SHLOBJ_H_
#pragma message("To avoid this message, put shlobj.h in your PCH (normally stdafx.h)")
#include <shlobj.h>
#endif

#ifndef _LM_
#pragma message("To avoid this message, put lm.h in your PCH (normally stdafx.h)")
#include <lm.h>
#endif

#ifndef __AFXMT_H__
#pragma message("To avoid this message, put afxmt.h in your PCH (normally stdafx.h)")
#include <afxmt.h>
#endif



//flags used to control how the DDX_FileTreeControl and SetFlags routine works

const DWORD TFC_SHOWFILES       = 0x0001;   //Control will show files aswell as show folders
const DWORD TFC_ALLOWDRAGDROP   = 0x0002;   //Control allows drag / drop
const DWORD TFC_ALLOWRENAME     = 0x0004;   //Control allows renaming of items
const DWORD TFC_ALLOWOPEN       = 0x0008;   //Control allows items to be "opened" by the shell
const DWORD TFC_ALLOWPROPERTIES = 0x0010;   //Control allows the "Properties" dialog to be shown
const DWORD TFC_ALLOWDELETE     = 0x0020;   //Control allows items to be deleted



//Allowable bit mask flags in SetDriveHideFlags / GetDriveHideFlags

const DWORD DRIVE_ATTRIBUTE_REMOVABLE   = 0x00000001;
const DWORD DRIVE_ATTRIBUTE_FIXED       = 0x00000002;
const DWORD DRIVE_ATTRIBUTE_REMOTE      = 0x00000004;
const DWORD DRIVE_ATTRIBUTE_CDROM       = 0x00000010;
const DWORD DRIVE_ATTRIBUTE_RAMDISK     = 0x00000020;



/////////////////////////// Classes /////////////////////////////////


//Class which gets stored int the item data on the tree control

class CTreeFileCtrlItemInfo
{
public:
//Constructors / Destructors
  CTreeFileCtrlItemInfo();
  CTreeFileCtrlItemInfo(const CTreeFileCtrlItemInfo& ItemInfo);
  ~CTreeFileCtrlItemInfo();

//Member variables
  CString       m_sFQPath;          //Fully qualified path for this item
  CString       m_sRelativePath;    //The relative bit of the path
  NETRESOURCE*  m_pNetResource;     //Used if this item is under Network Neighborhood
  BOOL          m_bNetworkNode;     //Item is "Network Neighborhood" or is underneath it
  BOOL          m_bExtensionHidden; //Is the extension being hidden for this item
};



//Class which encapsulates access to the System image list which contains
//all the icons used by the shell to represent the file system

class CSystemImageList
{
public:
//Constructors / Destructors
  CSystemImageList();
  ~CSystemImageList();

protected:
//Data
  CImageList m_ImageList;          //The MFC image list wrapper
  static int sm_nRefCount;         //Reference count for the imagelist

  friend class CTreeFileCtrl;      //Allow the FileTreeCtrl access to our internals
};




//Struct taken from svrapi.h as we cannot mix Win9x and Win NT net headers in one program
#pragma pack(1)
struct CTreeFile_share_info_50 
{
	char		shi50_netname[LM20_NNLEN+1];    /* share name */
	unsigned char 	shi50_type;                 /* see below */
  unsigned short	shi50_flags;                /* see below */
	char FAR *	shi50_remark;                   /* ANSI comment string */
	char FAR *	shi50_path;                     /* shared resource */
	char		shi50_rw_password[SHPWLEN+1];   /* read-write password (share-level security) */
	char		shi50_ro_password[SHPWLEN+1];   /* read-only password (share-level security) */
};	/* share_info_50 */
#pragma pack()



//class which manages enumeration of shares. This is used for determining 
//if an item is shared or not
class CShareEnumerator
{
public:
//Constructors / Destructors
  CShareEnumerator();
  ~CShareEnumerator();

//Methods
  void Refresh(); //Updates the internal enumeration list
  BOOL IsShared(const CString& sPath);

protected:
//Defines
  typedef NET_API_STATUS (WINAPI NT_NETSHAREENUM)(LPWSTR, DWORD, LPBYTE*, DWORD, LPDWORD, LPDWORD, LPDWORD);
  typedef NET_API_STATUS (WINAPI NT_NETAPIBUFFERFREE)(LPVOID);
  typedef NET_API_STATUS (WINAPI WIN9X_NETSHAREENUM)(const char FAR *, short, char FAR *, unsigned short, unsigned short FAR *, unsigned short FAR *);

//Data
  BOOL                     m_bWinNT;          //Are we running on NT
  HMODULE                  m_hNetApi;         //Handle to the net api dll
  NT_NETSHAREENUM*         m_pNTShareEnum;    //NT function pointer for NetShareEnum
  NT_NETAPIBUFFERFREE*     m_pNTBufferFree;   //NT function pointer for NetAPIBufferFree
  SHARE_INFO_502*          m_pNTShareInfo;    //NT share info
  WIN9X_NETSHAREENUM*      m_pWin9xShareEnum; //Win9x function pointer for NetShareEnum
  CTreeFile_share_info_50* m_pWin9xShareInfo; //Win9x share info
  DWORD                    m_dwShares;        //The number of shares enumerated
};



//Class which is used for passing info to and from the change notification
//threads

class CTreeFileCtrlThreadInfo
{
public:
//Constructors / Destructors
  CTreeFileCtrlThreadInfo();
  ~CTreeFileCtrlThreadInfo();

//Member variables
  CString        m_sPath;          //The path we are monitoring
  CWinThread*    m_pThread;        //The thread pointer
  CTreeFileCtrl* m_pTree;          //The tree control
  int            m_nIndex;         //Index of this item into CTreeFileCtrl::m_ThreadInfo
  CEvent         m_TerminateEvent; //Event using to terminate the thread
};



//Class which implements the tree control representation of the file system

class CTreeFileCtrl : public CTreeCtrl
{
public:
//Enums
enum HideFileExtension
{
  HideExtension,
  DoNoHideExtension,
  UseTheShellSetting
};

//Constructors / Destructors
	CTreeFileCtrl();
	virtual ~CTreeFileCtrl();

//Public methods
  void              SetRootFolder(const CString& sPath);
  CString           GetRootFolder() const { return m_sRootFolder; };
  CString           GetSelectedPath();
  HTREEITEM         SetSelectedPath(const CString& sPath, BOOL bExpanded=FALSE);
  void              SetShowFiles(BOOL bFiles);
  BOOL              GetShowFiles() const { return m_bShowFiles; };
  void              SetDisplayNetwork(BOOL bDisplayNetwork);
  BOOL              GetDisplayNetwork() const { return m_bDisplayNetwork; };
  void              SetUsingDifferentIconForSharedFolders(BOOL bShowSharedUsingDifferentIcon);
  BOOL              GetUsingDifferentIconForSharedFolders() const { return m_bShowSharedUsingDifferentIcon; };
  void              SetAllowDragDrop(BOOL bAllowDragDrop) { m_bAllowDragDrop = bAllowDragDrop; };
  BOOL              GetAllowDragDrop() const { return m_bAllowDragDrop; };
  void              SetAllowRename(BOOL bAllowRename) { m_bAllowRename = bAllowRename; };
  BOOL              GetAllowRename() const { return m_bAllowRename; };
  void              SetAllowOpen(BOOL bAllowOpen) { m_bAllowOpen = bAllowOpen; };
  BOOL              GetAllowOpen() const { return m_bAllowOpen; };
  void              SetAllowProperties(BOOL bAllowProperties) { m_bAllowProperties = bAllowProperties; };
  BOOL              GetAllowProperties() const { return m_bAllowProperties; };

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -