📄 hsortlistctrl.h
字号:
#if !defined(AFX_LISTCTRLEX_H__14D0592D_666B_11D1_B5EE_080009BD5569__INCLUDED_)
#define AFX_LISTCTRLEX_H__14D0592D_666B_11D1_B5EE_080009BD5569__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
/////////////////////////////////////////////////////////////////////////////
// CHeaderCtrlEx window
class AFX_EXT_CLASS CHeaderCtrlEx : public CHeaderCtrl
{
// Construction
public:
CHeaderCtrlEx();
CHeaderCtrlEx(CWnd* pWnd, void (CWnd::*fpDragCol)(int, int));
// Attributes
bool EnableDrag(bool bDrag=true);
public:
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CHeaderCtrlEx)
protected:
//}}AFX_VIRTUAL
// Implementation
public:
void DrawItem( LPDRAWITEMSTRUCT lpDrawItemStruct);
void SetSortArrow(const int nSortColumn,const BOOL bSortAscending);
virtual ~CHeaderCtrlEx();
void SetCallback(CWnd* pWnd, void (CWnd::*fpDragCol)(int, int));
protected:
bool m_bDragEnable;
int m_nSortColumn;
BOOL m_bSortAscending;
BOOL m_bCheckForDrag;
BOOL m_bDragging;
int *m_pWidth;
int m_nDragCol;
int m_nDropPos;
CRect marker_rect;
void (CWnd::*m_fpDragCol)(int, int);
CWnd *m_pOwnerWnd;
// Generated message map functions
protected:
//{{AFX_MSG(CHeaderCtrlEx)
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// CHSortListCtrl window
#define HIGHLIGHT_NORMAL 0
#define HIGHLIGHT_ALLCOLUMNS 1
#define HIGHLIGHT_ROW 2
#define LVEX_CASE 0
#define LVEX_NOCASE 1
#define LVEX_NUM 2 //integer
#define LVEX_TIME 3
#define LVEX_NOSORT 4
#define LVEX_NUM_FLOAT 5
#define LVEX_TIME_BASE 6 //probably will never use this
#define LVEX_LAST 7 //increment this if you add more types
#define LVEX_IP_ADDRESS1 8 //一个顺序的IP地址
#define LVEX_IP_ADDRESS2 9 //倒序的IP地址
#define UM_SEL_ITEM_CHANGE WM_USER+100
#define UM_ITEM_DBCLKED WM_USER+101
#define UM_HSLIST_ADD_ITEM WM_USER+4010
#define UM_HSLIST_RMV_ITEM WM_USER+4011
#define UM_HSLIST_UPT_ITEM WM_USER+4012
class AFX_EXT_CLASS CHSListAddItemMsg
{
public:
CHSListAddItemMsg(){
}
CHSListAddItemMsg(CHSListAddItemMsg &other){
*this=other;
}
CHSListAddItemMsg(int nItemIdx,
int nIcon,
CString strLable,
WORD dData){
m_nItemIdx=nItemIdx;
m_nIcon=nIcon;
m_strLable=strLable;
m_dData=dData;
}
CHSListAddItemMsg& operator=(CHSListAddItemMsg& other){
this->m_nItemIdx=other.m_nItemIdx;
this->m_nIcon=other.m_nIcon;
this->m_strLable=other.m_strLable;
this->m_dData=other.m_dData;
return *this;
}
int m_nItemIdx;
int m_nIcon;
CString m_strLable;
WORD m_dData;
};
#include "HADOSpirit.h"
class AFX_EXT_CLASS CHSortListCtrl : public CListCtrl,public CHADOSpirit
{
// Construction
public:
CHSortListCtrl();
// Attributes
int SetHighlightType(int hilite);
bool EnableSort(bool bSort=true);
void SetStyle(DWORD dwType);
bool SetColumnTypes(unsigned char* pColTypes, unsigned nColCnt);
bool EnableHeaderDrag(bool bDrag=true);
bool SetBaseTime(CString strTime);
public:
// Operations
void RmvItem(int nIdx);
void AddItem(int nIdx);
protected:
BOOL m_bForNetbarMainList;
CString m_strOldSelItemText;
public:
void ForNetbarMainList(BOOL bForNetbarMainList=FALSE);
protected:
CStringArray m_saHeaders;
CIntArray m_naHeaderWidths;
CIntArray m_naHeaderFormats;
int m_nHighlight; // Indicate type of selection highlighting
bool m_bSort; //set to false if you don't want to sort
unsigned char* m_pTypes;//column sort types
int m_nNumCols; //number of columns to sort
COleDateTime m_ctStart; //base time for sorting on 24hr clock
int nSortedCol;
BOOL bSortAscending;
BOOL m_bEditable;
CHeaderCtrlEx m_headerctrl;
BOOL m_bContextHelp;
virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
void RepaintSelectedItems();
void DragColumn(int source, int dest);
static int CALLBACK Compare(LPARAM lParam1, LPARAM lParam2, LPARAM
lParamSort);
//data structure for setdata
struct AFX_EXT_CLASS ListData
{
ListData(const DWORD dwOld, const CString &strTxt, const COleDateTime Start);
DWORD dwOldData;
CString strText;
COleDateTime BaseTime;
};
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CHSortListCtrl)
public:
virtual int OnToolHitTest(CPoint point, TOOLINFO* pTI) const;
virtual BOOL OnChildNotify(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pLResult);
protected:
virtual void PreSubclassWindow();
//}}AFX_VIRTUAL
// Implementation
public:
BOOL EnableContextHelp(BOOL bEnable);
BOOL SetEditable(BOOL bEditable);
int GetHeaderIndexByText(CString strText);
void SetHeaderInfos(CStringArray &saHeaders,CIntArray &naHeaderWidths,CIntArray &naHeaderFormats);
int GetRowByText(CString strText);
void InsertOneRow(WIN32_FIND_DATA *pWFD);
void InsertOneFolder(WIN32_FIND_DATA *pWFD);
void InsertOneSWF(WIN32_FIND_DATA *pWFD);
virtual ~CHSortListCtrl();
// Generated message map functions
protected:
//{{AFX_MSG(CHSortListCtrl)
afx_msg void OnPaint();
afx_msg void OnSetFocus(CWnd* pOldWnd);
afx_msg void OnKillFocus(CWnd* pNewWnd);
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnColumnclick(NMHDR* pNMHDR, LRESULT* pResult);
afx_msg void OnClick(NMHDR* pNMHDR, LRESULT* pResult);
afx_msg void OnKeydown(NMHDR* pNMHDR, LRESULT* pResult);
afx_msg void OnDblclk(NMHDR* pNMHDR, LRESULT* pResult);
//}}AFX_MSG
afx_msg void OnHeaderClicked(NMHDR* pNMHDR, LRESULT* pResult);
afx_msg BOOL OnToolTipText( UINT id, NMHDR * pNMHDR, LRESULT * pResult );
DECLARE_MESSAGE_MAP()
private:
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_LISTCTRLEX_H__14D0592D_666B_11D1_B5EE_080009BD5569__INCLUDED_)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -