一个CListctrl的扩展类

本文介绍了一个使用C++实现的CListctrl扩展类SortListCtrl,该类提供了排序功能和一些额外的方法,如插入列、设置排序列等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 一个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_)

 

可修改颜色的一个CListCtrlCl类 部分函数如下所示 public: 行高 int m nRowHeight; int InsertColumn int nCol LPCTSTR lpszColumnHeading int nFormat LVCFMT LEFT int nWidth 1 int nSubItem 1 ; public: Gradient 渐变系数 立体背景用 不用渐变设为0 void SetHeaderBKColor int R int G int B int Gradient ; public: 设置表头高度 void SetHeaderHeight float Height ; CPtrList m ptrListCol; 保存列颜色 CPtrList m ptrListItem; 保存Item颜色表 CPtrList m colTextColor; 保存列字体颜色 CPtrList m ItemTextColor; 保存单元格字体颜色 bool FindColColor int col COLORREF &color ; 查找列颜色 bool FindItemColor int col int row COLORREF &color ; bool FindColTextColor int col COLORREF &color ; 查找列字体颜色 bool FindItemTextColor int col int row COLORREF &color ; void SetColColor int col COLORREF color ; 设置列颜色 void SetItemColor int col int row COLORREF color ; 设置Item颜色 void SetColTextColor int col COLORREF color ; 设置列文本颜色 void SetItemTextColor int col int row COLORREF color ; void SetRowHeigt int nHeight ; 设置行高 void SetHeaderFontHW int nHeight int nWith ; 设置表头字体大小 void SetHeaderTextColor COLORREF color ; COLORREF m color; BOOL SetTextColor COLORREF cr ; void SetFontHW int nHeight int nWith ; 设置字体的高和宽 void EraseItemColor int col int row ; stColor FindItemColor2 int col int row COLORREF &color ; void EraseAllColor ;">可修改颜色的一个CListCtrlCl类 部分函数如下所示 public: 行高 int m nRowHeight; int InsertColumn int nCol LPCTSTR lpszColumnHeading int nFormat LVCFMT LEFT int nWidth 1 int nSubItem 1 ; public: Gradient 渐变系数 立体背景用 不用渐变设为0 [更多]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值