一个CListctrl的扩展类 http://blog.youkuaiyun.com/gavin_luo/article/details/3323862
/******SortListCtrl.h*****/
#if !defined(AFX_SORTLISTCTRL_H__F0BB8225_84D5_4E42_AA76_4671181B9F62__INCLUDED_)
#define AFX_SORTLISTCTRL_H__F0BB8225_84D5_4E42_AA76_4671181B9F62__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// SortListCtrl.h : header file
//#pragma once
#include "HeaderCtrlCl.h"
/////////////////////////////////////////////////////////////////////////////
// CSortListCtrl window
class CSortListCtrl : public CListCtrl
{
DECLARE_DYNAMIC(CSortListCtrl)
// Construction
public:
CSortListCtrl();
// Attributes
public:
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CSortListCtrl)
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CSortListCtrl();
// Generated message map functions
protected:
//{{AFX_MSG(CSortListCtrl)
// NOTE - the ClassWizard will add and remove member functions here.
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
virtual void PreSubclassWindow();
private:
DWORD m_nIndex;
public:
BOOL SignatureItem(int nItem);
int FindByIndex(DWORD nIndex);
void SetSortColumn(int nColumn);
int GetSortColumn();
public:
// 字体高度
int m_fontHeight;
public:
int InsertColumn(int nCol, LPCTSTR lpszColumnHeading,int nFormat = LVCFMT_LEFT, int nWidth = -1, int nSubItem = -1);
// 字体宽度
int m_fontWith;
public:
BOOL m_bSortAscending;
int m_nSortColumn;
};
int CALLBACK SortFunc(LPARAM lp1, LPARAM lp2, LPARAM lpSort);
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_SORTLISTCTRL_H__F0BB8225_84D5_4E42_AA76_4671181B9F62__INCLUDED_)