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

📄 disklistctrl.h

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

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// DiskListCtrl.h : header file
//
#include <afxtempl.h>

#include "Common/DiBitmap.h"

#define WM_DISKLIST_NOTIFY		WM_USER + 164
#define WM_DISKLIST_UPDATE		WM_USER + 165

/////////////////////////////////////////////////////////////////////////////
// CDiskListCtrl window



class CDiskListCtrl : public CWnd
{
// Construction
public:
	CDiskListCtrl();
	
	
	typedef struct tagTHREADPARAMS
	{
		char charPath[MAX_PATH];
		int nItemCode;
		
		int* pnThreadCode;
		int* pnFileCount;
		int* pnFolderCount;
		long double* pldTotalSpace;
		LPARAM lParam;
	}THREADPARAMS;
// Attributes
public:
	class CItemInfo;
	typedef CTypedPtrArray<CObArray, CItemInfo*> CItemArray;
		
	CItemArray m_arrayFolder, m_arrayDrive;

	CFont m_fontTitle;
	CImageList m_imgTypeList;

	BOOL m_bEnableBackground;
	CDIBitmap m_bmpDriveBack, m_bmpFreeBack, m_bmpTotalBack, 
		m_bmpFolderBack, m_bmpHighBack, m_bmpPressedBack;

	int m_nMouseInCode; //0-n buttons -1 - -6 title bar
	int m_nMouseDownCode;
	BOOL m_bMouseDown;

	double m_dRedAlert;
	double m_dYellowAlert;

	int m_nNrThread;

// Operations
public:

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CDiskListCtrl)
	public:
	virtual BOOL Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext = NULL);
	//}}AFX_VIRTUAL

// Implementation
public:
	void EmptyFolderArray();
	void OnItemUpdate(WPARAM wParam, LPARAM lParam);
	void UpdateAbortedFolders();
	void OnStartUpdate(int n);
	void OnFinishedUpdate(int n);
	void OnPause();
	void OnStopAll();
	int GetSize();
	static int CompareItemSize(const void* f1, const void* f2);
	static int m_nSortCode;
	void SortItems(int n);
	void RedrawItem(int i);
	int HitTestEx(CPoint pt);
	void GetTotalUsage(int& nCount, long double& ldTotal, long double& ldFree);
	void InitCtrl();
	void Update(BOOL bFolders = FALSE);
	void DrawTotalItem(CDC *pDC, const CRect& rcClient);
	void DrawDrive(CDC* pDC, const CRect& rcClient, int nItem);
	void DrawFolder(CDC* pDC, const CRect& rcClient, int nItem);
	int GetFolderSize();
	int GetDriveSize();
	int GetItemHeight(const CRect& rcClient, BOOL bTitle=FALSE);
	void GetItemRect(const CRect &rcClient, CRect& rc, int nType, int nPos);
	void DeleteAll();
	BOOL AddFolder(const CString& str);
	BOOL AddDrive(const CString& str);
	virtual ~CDiskListCtrl();

	// Generated message map functions
protected:
	//{{AFX_MSG(CDiskListCtrl)
	afx_msg void OnPaint();
	afx_msg BOOL OnEraseBkgnd(CDC* pDC);
	afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
	afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
	afx_msg void OnMouseMove(UINT nFlags, CPoint point);
	afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
	afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
	afx_msg void OnTimer(UINT nIDEvent);
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

class CDiskListCtrl::CItemInfo : public CObject
{
public:
	inline BOOL GetFinished();
	void StopThread();
	CDiskListCtrl* m_pCtrl;
	static UINT ThreadFunc(LPVOID);
	static void UpdateDir(THREADPARAMS* pThreadParams);

	void UpdateFolder(int nItemCode);
	double GetUsage();
	void Reset();
	BOOL Update();
	CItemInfo(CDiskListCtrl* pCtrl);
	~CItemInfo();

	//BOOL	m_bIsDrive;
	BOOL	m_bAvailable;
	UINT	m_nDriveType;

	CString m_strDriveName;		// Folder Name in folder mode
	CString	m_strTitle;			// E.g. (C:) System 
	CString	m_strPartitionType;

	int m_nFileCount;
	int m_nFolderCount;
	long double m_ldTotalSpace;
	long double m_ldFreeSpace;

	CWinThread* m_pThread;
	int m_nThreadCode; // -1 terminat 0 pause 1 continue
};



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

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

#endif // !defined(AFX_DISKLISTCTRL_H__A1B4C7A9_A445_11D2_9363_0080C8E7F1DB__INCLUDED_)

⌨️ 快捷键说明

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