SortListCtrl.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. #ifndef SORTLISTCTRL_H
  2. #define SORTLISTCTRL_H
  3. #if _MSC_VER > 1000
  4. #pragma once
  5. #endif // _MSC_VER > 1000
  6. #ifndef SORTHEADERCTRL_H
  7. #include "SortHeaderCtrl.h"
  8. #endif // SORTHEADERCTRL_H
  9. #ifdef _DEBUG
  10. #define ASSERT_VALID_STRING( str ) ASSERT( !IsBadStringPtr( str, 0xfffff ) )
  11. #else // _DEBUG
  12. #define ASSERT_VALID_STRING( str ) ( (void)0 )
  13. #endif // _DEBUG
  14. class CSortListCtrl :public CListCtrl
  15. {
  16. // Construction
  17. public:
  18. CSortListCtrl();
  19. // Attributes
  20. public:
  21. // Operations
  22. public:
  23. BOOL SetHeadings( UINT uiStringID );
  24. BOOL SetHeadings( const CString& strHeadings );
  25. int AddItem( LPCTSTR pszText, ... );
  26. BOOL DeleteItem( int iItem );
  27. BOOL DeleteAllItems();
  28. void LoadColumnInfo();
  29. void SaveColumnInfo();
  30. BOOL SetItemText( int nItem, int nSubItem, LPCTSTR lpszText );
  31. void Sort( int iColumn, BOOL bAscending );
  32. BOOL SetItemData(int nItem, DWORD dwData);
  33. DWORD GetItemData(int nItem) const;
  34. // Overrides
  35. // ClassWizard generated virtual function overrides
  36. //{{AFX_VIRTUAL(CSortListCtrl)
  37. protected:
  38. virtual void PreSubclassWindow();
  39. //}}AFX_VIRTUAL
  40. // Implementation
  41. public:
  42. void SetItemColor(int nItem, int nSubItem, COLORREF clrText, COLORREF clrBkgnd);
  43. void DrawText(int nItem, int nSubItem, CDC *pDC, COLORREF crText, COLORREF crBkgnd, CRect &rect);
  44. BOOL GetSubItemRect(int nItem, int nSubItem, int nArea, CRect& rect);
  45. int GetColumns();
  46. int AddItemColor(LPCTSTR pszText,COLORREF crText,COLORREF crBak);
  47. virtual ~CSortListCtrl();
  48. // Generated message map functions
  49. protected:
  50. void UpdateSubItem(int nItem, int nSubItem);
  51. static int CALLBACK CompareFunction( LPARAM lParam1, LPARAM lParam2, LPARAM lParamData );
  52. void FreeItemMemory( const int iItem );
  53. BOOL CSortListCtrl::SetArray( int iItem, LPTSTR* arrpsz ,COLORREF * clrText,COLORREF * clrBak);
  54. LPTSTR* CSortListCtrl::GetTextArray( int iItem ) const;
  55. CSortHeaderCtrl m_ctlHeader;
  56. int m_iNumColumns;
  57. int m_iSortColumn;
  58. BOOL m_bSortAscending;
  59. //{{AFX_MSG(CSortListCtrl)
  60. afx_msg void OnColumnClick(NMHDR* pNMHDR, LRESULT* pResult);
  61. afx_msg void OnDestroy();
  62. afx_msg void OnPaint();
  63. afx_msg void OnCustomDraw(NMHDR* pNMHDR, LRESULT* pResult);
  64. afx_msg void OnSysColorChange();
  65. //}}AFX_MSG
  66. DECLARE_MESSAGE_MAP()
  67. private:
  68. COLORREF crWindowText,crWindow,crHighLight,crHighLightText;
  69. };
  70. //{{AFX_INSERT_LOCATION}}
  71. // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
  72. #endif // SORTLISTCTRL_H