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

📄 mylistctrl.h

📁 我上载了那么多怎么都说已经有上载的啦
💻 H
字号:
#if !defined(AFX_MYLISTCTRL_H__41DCCA40_8D99_11D3_901A_0000B4B0B41F__INCLUDED_)
#define AFX_MYLISTCTRL_H__41DCCA40_8D99_11D3_901A_0000B4B0B41F__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// MyListCtrl.h : header file
//

/////////////////////////////////////////////////////////////////////////////
// CMyListCtrl window

enum ListCompareType {  ELCT_INTEGER = 0,
ELCT_DOUBLE,
ELCT_STRING_CASE,
ELCT_DATETIME,
ELCT_STRING_NOCASE };
enum ListOperatorType { 
	ELOT_LT = 0,    //  <   less than
	ELOT_GT,  //  >   greater than
	ELOT_LTE, //  <=  less than or equal
	ELOT_GTE, //  >=  greather than or equal
	ELOT_EQ}; //  ==  equal

enum DLDropFlags
{
	DL_ACCEPT_FILES =       0x01,	// Allow files to be dropped
	DL_ACCEPT_FOLDERS =		0x02,	// Allow folders to be droppped
	DL_ALLOW_DUPLICATES =	0x04,	// Allow a pathname to be dropped even if its already in the list (ignored if you specify a callback function)
	DL_FILTER_EXTENSION =	0x10,	// Only accept files with the specified extension. Specify in csFileExt
	DL_USE_CALLBACK =		0x20,	// Receive a callback for each item dropped, specified in pfnCallback (you have responsibility for inserting items into the list)

	DL_FOLDER_TYPE =		0x40,	// Returned to the callback function - indicating the type of path dropped
	DL_FILE_TYPE =			0x80
};

typedef HRESULT (CALLBACK FAR * LPFN_DROP_FILES_CALLBACK)(CListCtrl*, const CString&, const UINT&);

class CMyListCtrl  : public CListCtrl
{
//////////////////////////////////////////////////////////////////////
// Constructors and Deconstructors
//////////////////////////////////////////////////////////////////////..
public:
	CMyListCtrl();
	virtual ~CMyListCtrl();
//////////////////////////////////////////////////////////////////////
// Operations
//////////////////////////////////////////////////////////////////////public:
	BOOL SwapRow(int nRow1, int nRow2);
	int GetColumnCount() const;
	void SetColumnType(int nColumnType[])
	{
		memcpy(m_nColumnType,nColumnType,64*sizeof(int));
	}
//[ 2007.04.08 
	void SetColumnCtrl(int nColumnCtrl[])
	{
		memcpy(m_nColumnCtrl,nColumnCtrl,64*sizeof(int));
	}
	CStringList& GetStringList(int index) {
		return m_strList[index];
	}
	void SetCanEdit(BOOL bCanEdit[])
	{
		memcpy(m_bCanEdit,bCanEdit,64*sizeof(int));
	}
	void SetDisableRow(int nDisableStartRow, int nDisableEndRow)
	{
		if( nDisableStartRow >=0 && nDisableEndRow >=0 && nDisableStartRow <= nDisableEndRow )
		{
			m_nDisableStartRow = nDisableStartRow; 
			m_nDisableEndRow = nDisableEndRow; 
		}
	}
// 2007.04.08 ]
	void SetSortFirstCol(BOOL bSortFirstCol)
	{
		m_bSortFirstCol = bSortFirstCol;
	}
	void SetMinColumnWidth(int nMinColumnWidth) {
		m_nMinColumnWidth = nMinColumnWidth;
	}
	void SetMaxColumnWidth(int nMaxColumnWidth) {
		m_nMaxColumnWidth = nMaxColumnWidth;
	}
	int AddRow( const LVITEM* pItem );
	int AddRow(int nRow, LPCTSTR lpszItem );
	int DeleteRow(int nRow);
	
	void ExpandColumns(UINT nStringID,CString& strPre,int starcount=0);
	int InsertItems(int nItem, CString lpszItems,UINT nStringID);
	void UpdateCell(int row, int col, LPCTSTR str, int icon = -1);
	void InitializeClear();

	struct DROPLISTMODE { 
		UINT iMask;								// Specifies what type of items to accept - a combination of the above flags
		CString csFileExt;						// The file extension on which to filter. Use the format ".extension". Ignored unless DL_FILTER_EXTENSION is specified
		LPFN_DROP_FILES_CALLBACK pfnCallback;	// Address of your callback function. Ignored unless DL_USE_CALLBACK is specified
	}; 
	struct CMultiHeadIndex
	{
		int iStartCol;
		int iColCount;
		CString strName;
	};

	BOOL SetDropMode(const CMyListCtrl::DROPLISTMODE& dropMode);
	DROPLISTMODE GetDropMode() const { return m_dropMode; };

protected:
//[ 2007.04.08
	CComboBox * ComboItem( int nItem,  int nSubItem);
	CEdit * EditItem( int nItem, int nSubItem);
// 2007.04.08 ]


	int GetMultiHeadIndex(CString & strName);
	void AddColumn(LPCTSTR str, int col);
	
	void DeleteItem(int ) {
	}
	
	void QuickSort(int p, int r);
	int Partition(int p, int r);

	COleDateTime ParseDateTime(LPCTSTR lpszDate);
//////////////////////////////////////////////////////////////////////
// Overridables
//////////////////////////////////////////////////////////////////////public:
	virtual void Sort();
	virtual void Sort(int nColumn, BOOL bAscending, ListCompareType nCompareAs);
protected:
	virtual BOOL CompareBy(CString str1, CString str2, ListOperatorType op);

	virtual BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult); 
//////////////////////////////////////////////////////////////////////
// Message Maps
//////////////////////////////////////////////////////////////////////protected:
	//{{AFX_MSG(OGPuiODListCtrl)
		afx_msg void OnHeaderClicked(NMHDR* pNMHDR, LRESULT* pResult);
		afx_msg void OnDropFiles(HDROP dropInfo);
		afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
		afx_msg void PreSubclassWindow();
		afx_msg BOOL OnToolTipText( UINT id, NMHDR * pNMHDR, LRESULT * pResult );
		afx_msg void OnEndlabeledit(NMHDR* pNMHDR, LRESULT* pResult);
		afx_msg void OnClick(NMHDR* pNMHDR, LRESULT* pResult);
		afx_msg void OnKeydown(NMHDR* pNMHDR, LRESULT* pResult);
	//}}AFX_MSG
//////////////////////////////////////////////////////////////////////
// Attributes
//////////////////////////////////////////////////////////////////////
protected:
//sorting attributes
	int m_nColumnType[64];
	int m_nSortedColumn;
	BOOL m_bSortAscending;
	ListCompareType m_nCompareAs;
	int m_nDateTimeType; 	//YYYYMMDD = 0,	YYYY/M/D = 1, YYYY-M-D = 2

	BOOL m_bSortFirstCol;

	int m_nMinColumnWidth;
	int m_nMaxColumnWidth;

//[ 2007.04.08	
	int m_nColumnCtrl[64];
	CStringList m_strList[64]; 
	BOOL m_bCanEdit[64];
	int m_nDisableStartRow; 
	int m_nDisableEndRow; 
// 2007.04.08	]

	virtual int InsertPathname(const CString& csFilename);
	virtual int OnToolHitTest(CPoint point, TOOLINFO * pTI) const;
	int CellRectFromPoint(CPoint & point, RECT * cellrect, int * col) const;

private:
	class CMultiHeadArray : public CArray<CMultiHeadIndex, CMultiHeadIndex&>	
	{
	public:
		int SetItem(int iStartCol,int iColCount,CString strName);
	} m_MultiHeadArray;


	DROPLISTMODE m_dropMode;
	BOOL m_bMustUninitOLE;

	CString ExpandShortcut(CString& csFilename) const;
	BOOL ValidatePathname(const CString& csPathname, UINT& iPathType) const;

	// Prevent default compiler generation of these copy constructors (no bitwise copy)
	CMyListCtrl& operator=(const CMyListCtrl& x);
	CMyListCtrl(const CMyListCtrl& x);

	DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////

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

#endif // !defined(AFX_MYLISTCTRL_H__41DCCA40_8D99_11D3_901A_0000B4B0B41F__INCLUDED_)

⌨️ 快捷键说明

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