Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

142 lines
3.6 KiB

  1. //============================================================================
  2. // Copyright (C) Microsoft Corporation, 1996 - 1999
  3. //
  4. // File: lcx.h
  5. //
  6. // History:
  7. // 07/13/96 Abolade Gbadegesin Created, based on C code by Steve Cobb
  8. //
  9. // Contains declarations for an enhanced list-control.
  10. //============================================================================
  11. #ifndef _LISTCTRL_H_
  12. #define _LISTCTRL_H_
  13. //
  14. // Notification sent by CListCtrlEx when an item's checked state changes.
  15. //
  16. #define LVXN_SETCHECK (LVN_LAST + 1)
  17. //----------------------------------------------------------------------------
  18. // Structs: SLcxRow
  19. // SLcxColumn
  20. //
  21. // Describes rows and columns in customizable list-controls.
  22. //----------------------------------------------------------------------------
  23. struct SLcxRow {
  24. UINT uiRowId;
  25. UINT idsTitle;
  26. BOOL bEnabled;
  27. };
  28. struct SLcxColumn {
  29. INT iSubItem;
  30. UINT idsTitle;
  31. INT cx;
  32. BOOL bEnabled;
  33. INT iIndex;
  34. };
  35. //----------------------------------------------------------------------------
  36. // Class: CListCtrlEx
  37. //
  38. // Controls a list-control which has extended capabilities,
  39. // including the ability to show checkboxes next to its items,
  40. // and the ability to maintain row-information in the registry.
  41. //----------------------------------------------------------------------------
  42. class CListCtrlEx : public CListCtrl
  43. {
  44. DECLARE_DYNAMIC(CListCtrlEx)
  45. public:
  46. CListCtrlEx()
  47. : m_pimlChecks(NULL), m_pimlOldState(NULL)
  48. { }
  49. virtual ~CListCtrlEx( );
  50. enum {
  51. LCXI_UNCHECKED = 1,
  52. LCXI_CHECKED = 2
  53. };
  54. INT GetColumnCount( );
  55. BOOL SetColumnText(INT iCol, LPCTSTR pszText, INT fmt = LVCFMT_LEFT );
  56. BOOL SetColumnText(INT iCol, UINT nID, INT fmt = LVCFMT_LEFT)
  57. {
  58. CString sCol;
  59. sCol.LoadString(nID);
  60. return SetColumnText(iCol, sCol, fmt);
  61. }
  62. //--------------------------------------------------------------------
  63. // Functions: InstallChecks
  64. // UninstallChecks
  65. // GetCheck
  66. // SetCheck
  67. //
  68. // Checkbox-handling functions.
  69. //--------------------------------------------------------------------
  70. BOOL InstallChecks( );
  71. VOID UninstallChecks( );
  72. BOOL GetCheck(INT iItem );
  73. VOID SetCheck( INT iItem, BOOL fCheck );
  74. protected:
  75. CImageList* m_pimlChecks;
  76. CImageList* m_pimlOldState;
  77. //{{AFX_MSG(CListCtrlEx)
  78. afx_msg VOID OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
  79. afx_msg VOID OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
  80. afx_msg VOID OnLButtonDown(UINT nFlags, CPoint pt);
  81. //}}AFX_MSG
  82. DECLARE_MESSAGE_MAP()
  83. };
  84. //----------------------------------------------------------------------------
  85. // Function: AdjustColumnWidth
  86. //
  87. // Called to adjust the width of column 'iCol' so that the string 'pszContent'
  88. // can be displayed in the column without truncation.
  89. //
  90. // If 'NULL' is specified for 'pszContent', the function adjusts the column
  91. // so that the first string in the column is displayed without truncation.
  92. //
  93. // Returns the new width of the column.
  94. //----------------------------------------------------------------------------
  95. INT
  96. AdjustColumnWidth(
  97. IN CListCtrl& listCtrl,
  98. IN INT iCol,
  99. IN LPCTSTR pszContent
  100. );
  101. INT
  102. AdjustColumnWidth(
  103. IN CListCtrl& listCtrl,
  104. IN INT iCol,
  105. IN UINT idsContent
  106. );
  107. #endif // _LISTCTRL_H_