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

📄 disktreectrl.h

📁 磁盘容量扫描、但界面和程序结构非常不错
💻 H
字号:
#if !defined(AFX_DISKTREECTRL_H__8C14512F_A6A3_11D2_936E_0080C8E7F1DB__INCLUDED_)
#define AFX_DISKTREECTRL_H__8C14512F_A6A3_11D2_936E_0080C8E7F1DB__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// DiskTreeCtrl.h : header file
//
#include "SuperGridCtrl.h"
#include "Common/FlatHeaderCtrl.h"

/////////////////////////////////////////////////////////////////////////////
// CDiskTreeCtrl window

#define WM_USER_SCANPROGRESS WM_USER + 102

#define SCAN_PROGRESS_SET_RANGE		1
#define SCAN_PROGRESS_SET_POS		2
#define SCAN_PROGRESS_FINISHED		3

class CDiskTreeCtrl;
class CTreeListPrinting
{
public:
	CTreeListPrinting();//Constructor
	BOOL OnPreparePrinting(CPrintInfo* pInfo, CView * cview, CDiskTreeCtrl * t_lc);//Guess # of pages
	void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo, CString & t_title, CString & t_date);
	void OnPrint(CDC* pDC, CPrintInfo* pInfo);
	void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);
	
protected:
	//vars
	CDiskTreeCtrl * lc;//List Control Pointer
	CString TitleStr;
	CString DateStr;
	
	CFont * pOldFont;//Font stuff
	CFont BoldFont;
	CFont lcFont;
	
	CRect page_rc;//Scaling Vars
	int m_nRowHeight;
	int m_nRowsPerPage;
	int m_nMaxRowCount;
	int hc_items;
	unsigned int m_ratiox;//These two are for scaling output to the printer
	unsigned int m_ratioy;
	
	//Protected functions------
	void PrintHeaderControl(CDC *pDC, CPrintInfo *pInfo);
	void PrintHeader(CDC *pDC, CPrintInfo *pInfo);
	void PrintFooter(CDC *pDC, CPrintInfo *pInfo);
	void DrawRow(CDC *pDC, int nItem);
	void draw_line_at(CDC *pDC, unsigned int y);
	void compute_metrics(CDC *pDC);
};

class CDiskTreeCtrl : public CSuperGridCtrl
{
	double m_dCurFileSize;

	int DrawRow(CDC *pDC, const CRect& rc, int nItem);

	CFlatHeaderCtrl m_wndFlatHeader;
// Construction
public:
	CDiskTreeCtrl();

	CTreeListPrinting lpr;
	int DrawLine(CDC* pDC, int nItem, const CRect& rc); // return Offset;

	BOOL OnPreparePrinting(CPrintInfo* pInfo, CView * cview)
		{return lpr.OnPreparePrinting(pInfo, cview, this);}
	void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo, CString & t_title, CString & t_date)
		{lpr.OnBeginPrinting(pDC, pInfo, t_title, t_date);}
	void OnPrint(CDC* pDC, CPrintInfo* pInfo)
		{lpr.OnPrint(pDC, pInfo);}
	void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo)
		{lpr.OnEndPrinting(pDC, pInfo);}


// Attributes
public:
	CImageList m_imgList;
	CMyFolder* m_pFolder;

	typedef struct tagDISKTREETHREADPARAMS
	{
		CDiskTreeCtrl* pTreeCtrl;
		CMyFolder* pFolder;
		CTreeItem* pTreeItem;

		double*			pdFileSize;
		double			dTotalUsed;
		bool bIsFolder;
		
		CWnd* pWnd;
		int* pnThreadCode;
	}DISKTREETHREADPARAMS;

	CWinThread* m_pThread;
	int m_nThreadCode;

// Operations
public:

	static UINT ThreadFunc(LPVOID);
	static void UpdateDir(CMyFolder * pCurDir, const char * charPath, 
		long double & dFileSize, CDiskTreeCtrl* pTreeCtrl,
		CDiskTreeCtrl::CTreeItem* pTreeItem,
		int* pnThreadCode, CWnd* pWnd, 
		DISKTREETHREADPARAMS* pThreadParams, bool bIsFolder, bool bRootFolder=false);
	static int nOldProgress;
	static long double dTotalUsedSize;

	CMyFolder* GetSelectedFolder();

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CDiskTreeCtrl)
	//}}AFX_VIRTUAL

// Implementation
public:
	void BuildItemRow(CTreeItem* pItem, CTreeItem* pRoot);
	void BuildTreeToHTML();
	void PrintTree(CDC* pDC, const CPoint& ptStart, const CSize& szSize, int nStart, int nEnd);
	static int GetNrSubFolders(LPCTSTR strRoot, bool bSub=false);
	CString GetSelectedPath();
	CString GetItemPath(CTreeItem* pItem);
	static int CompareChildren(const void* p1, const void* p2);
	static int m_nSortCol;
	static BOOL m_bSortAscending;
	void Sort(CTreeItem* pParent);
	void Stop();
	int GetIcon(const CTreeItem* pItem);
	CString GetCurrentFolder();
	void OnGetdispinfo(NMHDR* pNMHDR, LRESULT* pResult);
	void DeleteAll();
	void ResizeColumns(BOOL bInit=FALSE);
	void UpdateFolders();
	virtual ~CDiskTreeCtrl();

	afx_msg void OnColumnClick(NMHDR* pNMHDR, LRESULT* pResult);

	// Generated message map functions
protected:
	//{{AFX_MSG(CDiskTreeCtrl)
	afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
	afx_msg void OnSize(UINT nType, int cx, int cy);
	//}}AFX_MSG

	DECLARE_MESSAGE_MAP()
};

/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_DISKTREECTRL_H__8C14512F_A6A3_11D2_936E_0080C8E7F1DB__INCLUDED_)

⌨️ 快捷键说明

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