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.

237 lines
7.9 KiB

  1. //============================================================================
  2. // Copyright (c) 1995, Microsoft Corporation
  3. //
  4. // File: treelist.h
  5. //
  6. // History:
  7. // Abolade Gbadegesin Nov-20-1995 Created.
  8. //
  9. // The control whose declarations are included here provides a view
  10. // which is a hybrid treeview/listview. Like a listview, each item
  11. // may have zero or more subitems. Like a treeview, items are organized
  12. // hierarchically, and displayed as a n-ary tree.
  13. //
  14. // [ Header1 ][ Header2
  15. // -- Level 1 subtext
  16. // |- Level 2 subtext
  17. // | |- Level 3
  18. // | +- Level 3
  19. // |- Level 2 subtext
  20. // +- Level 2
  21. // +- Level 1 subtext
  22. //
  23. //
  24. // The control is implemented as window which provides item-management,
  25. // and which contains a listview window to which display is delegated.
  26. //
  27. // Once the window class has been initialized by calling TL_Init(),
  28. // a treelist window can be created by calling CreateWindow() or
  29. // CreateWindowEx() and passing it WC_TREELIST as the name of the class
  30. // of window to be created.
  31. //
  32. // Communication with the window is via message passing, and macros are
  33. // provided below for the operations supported by the treelist.
  34. //
  35. // As with a listview, at least one column must be inserted into the treelist
  36. // before inserted items are displayed. Columns are described using
  37. // the LV_COLUMN structure defined in commctrl.h. Use the macros
  38. // TreeList_InsertColumn() and TreeList_DeleteColumn() for column management.
  39. //
  40. // Item insertion and deletion shoudl be done with TreeList_InsertItem() and
  41. // TreeList_DeleteItem(). The insertion macro takes a TL_INSERTSTRUCT,
  42. // which contains a pointer to a LV_ITEM structure which, as with listviews,
  43. // is used to describe the item to be inserted. The LV_ITEM structure
  44. // is defined in commctrl.h. (Note the iItem field is ignored).
  45. // As with a treeview, once items have been inserted, there are referred to
  46. // via handles. The type for treelist handles is HTLITEM.
  47. //
  48. // Once an item has been inserted, its attributes can be retreived or changed,
  49. // it can be deleted, and subitems can be set for it. The LV_ITEM structure
  50. // is used to retrieve or set an items attributes, and the iItem field
  51. // is used to store the HTLITEM of the item to which the operation refers.
  52. //
  53. //============================================================================
  54. #ifndef _TREELIST_H_
  55. #define _TREELIST_H_
  56. //
  57. // Window class name string
  58. //
  59. #define WC_TREELIST TEXT("TreeList")
  60. //
  61. // Item handle definition
  62. //
  63. typedef VOID *HTLITEM;
  64. //
  65. // struct passed to TreeList_InsertItem
  66. //
  67. typedef struct _TL_INSERTSTRUCT {
  68. HTLITEM hParent;
  69. HTLITEM hInsertAfter;
  70. LV_ITEM *plvi;
  71. } TL_INSERTSTRUCT;
  72. //
  73. // values for TL_INSERTSTRUCT::hInsertAfter
  74. //
  75. #define TLI_FIRST ((HTLITEM)UlongToPtr(0xffff0001))
  76. #define TLI_LAST ((HTLITEM)UlongToPtr(0xffff0002))
  77. #define TLI_SORT ((HTLITEM)UlongToPtr(0xffff0003))
  78. //
  79. // struct sent in notifications by a treelist
  80. //
  81. typedef struct _NMTREELIST {
  82. NMHDR hdr;
  83. HTLITEM hItem;
  84. LPARAM lParam;
  85. } NMTREELIST;
  86. //
  87. // flags for TreeList_GetNextItem
  88. //
  89. #define TLGN_FIRST 0x0000
  90. #define TLGN_PARENT 0x0001
  91. #define TLGN_CHILD 0x0002
  92. #define TLGN_NEXTSIBLING 0x0004
  93. #define TLGN_PREVSIBLING 0x0008
  94. #define TLGN_ENUMERATE 0x0010
  95. #define TLGN_SELECTION 0x0020
  96. //
  97. // flags for TreeList_Expand
  98. //
  99. #define TLE_EXPAND 0x0001
  100. #define TLE_COLLAPSE 0x0002
  101. #define TLE_TOGGLE 0x0003
  102. #define TLM_FIRST (WM_USER + 1)
  103. #define TLM_INSERTITEM (TLM_FIRST + 0)
  104. #define TLM_DELETEITEM (TLM_FIRST + 1)
  105. #define TLM_DELETEALLITEMS (TLM_FIRST + 2)
  106. #define TLM_GETITEM (TLM_FIRST + 3)
  107. #define TLM_SETITEM (TLM_FIRST + 4)
  108. #define TLM_GETITEMCOUNT (TLM_FIRST + 5)
  109. #define TLM_GETNEXTITEM (TLM_FIRST + 6)
  110. #define TLM_EXPAND (TLM_FIRST + 7)
  111. #define TLM_SETIMAGELIST (TLM_FIRST + 8)
  112. #define TLM_GETIMAGELIST (TLM_FIRST + 9)
  113. #define TLM_INSERTCOLUMN (TLM_FIRST + 10)
  114. #define TLM_DELETECOLUMN (TLM_FIRST + 11)
  115. #define TLM_SETSELECTION (TLM_FIRST + 12)
  116. #define TLM_REDRAW (TLM_FIRST + 13)
  117. #define TLM_ISITEMEXPANDED (TLM_FIRST + 14)
  118. #define TLM_GETCOLUMNWIDTH (TLM_FIRST + 15)
  119. #define TLM_SETCOLUMNWIDTH (TLM_FIRST + 16)
  120. #define TLN_FIRST (0U - 1000U)
  121. #define TLN_DELETEITEM (TLN_FIRST - 1)
  122. #define TLN_SELCHANGED (TLN_FIRST - 2)
  123. BOOL
  124. TL_Init(
  125. HINSTANCE hInstance
  126. );
  127. #define TreeList_InsertItem(hwnd, ptlis) \
  128. (HTLITEM)SendMessage( \
  129. (hwnd), TLM_INSERTITEM, 0, (LPARAM)(CONST TL_INSERTSTRUCT *)(ptlis)\
  130. )
  131. #define TreeList_DeleteItem(hwnd, hItem) \
  132. (BOOL)SendMessage( \
  133. (hwnd), TLM_DELETEITEM, 0, (LPARAM)(CONST HTLITEM)(hItem) \
  134. )
  135. #define TreeList_DeleteAllItems(hwnd) \
  136. (BOOL)SendMessage((hwnd), TLM_DELETEALLITEMS, 0, 0)
  137. #define TreeList_GetItem(hwnd, pItem) \
  138. (BOOL)SendMessage( \
  139. (hwnd), TLM_GETITEM, 0, (LPARAM)(LV_ITEM *)(pItem) \
  140. )
  141. #define TreeList_SetItem(hwnd, pItem) \
  142. (BOOL)SendMessage( \
  143. (hwnd), TLM_SETITEM, 0, (LPARAM)(CONST LV_ITEM *)(pItem) \
  144. )
  145. #define TreeList_GetItemCount(hwnd) \
  146. (UINT)SendMessage((hwnd), TLM_GETITEMCOUNT, 0, 0)
  147. #define TreeList_GetNextItem(hwnd, hItem, flag) \
  148. (HTLITEM)SendMessage( \
  149. (hwnd), TLM_GETNEXTITEM, (WPARAM)(UINT)(flag), \
  150. (LPARAM)(CONST HTLITEM)(hItem) \
  151. )
  152. #define TreeList_GetFirst(hwnd) \
  153. TreeList_GetNextItem((hwnd), NULL, TLGN_FIRST)
  154. #define TreeList_GetParent(hwnd, hItem) \
  155. TreeList_GetNextItem((hwnd), (hItem), TLGN_PARENT)
  156. #define TreeList_GetChild(hwnd, hItem) \
  157. TreeList_GetNextItem((hwnd), (hItem), TLGN_CHILD)
  158. #define TreeList_GetNextSibling(hwnd, hItem) \
  159. TreeList_GetNextItem((hwnd), (hItem), TLGN_NEXTSIBLING)
  160. #define TreeList_GetPrevSibling(hwnd, hItem) \
  161. TreeList_GetNextItem((hwnd), (hItem), TLGN_PREVSIBLING)
  162. #define TreeList_GetEnumerate(hwnd, hItem) \
  163. TreeList_GetNextItem((hwnd), (hItem), TLGN_ENUMERATE)
  164. #define TreeList_GetSelection(hwnd) \
  165. TreeList_GetNextItem((hwnd), NULL, TLGN_SELECTION)
  166. #define TreeList_Expand(hwnd, hItem, flag) \
  167. (BOOL)SendMessage( \
  168. (hwnd), TLM_EXPAND, (WPARAM)(UINT)(flag), \
  169. (LPARAM)(CONST HTLITEM)(hItem) \
  170. )
  171. #define TreeList_SetImageList(hwnd, himl) \
  172. (BOOL)SendMessage( \
  173. (hwnd), TLM_SETIMAGELIST, 0, (LPARAM)(CONST HIMAGELIST)(himl) \
  174. )
  175. #define TreeList_GetImageList(hwnd, himl) \
  176. (HIMAGELIST)SendMessage((hwnd), TLM_GETIMAGELIST, 0, 0)
  177. #define TreeList_InsertColumn(hwnd, iCol, pCol) \
  178. (INT)SendMessage( \
  179. (hwnd), TLM_INSERTCOLUMN, (WPARAM)(INT)(iCol), \
  180. (LPARAM)(CONST LV_COLUMN *)(pCol) \
  181. )
  182. #define TreeList_DeleteColumn(hwnd, iCol) \
  183. (BOOL)SendMessage((hwnd), TLM_DELETECOLUMN, (WPARAM)(INT)(iCol), 0)
  184. #define TreeList_SetSelection(hwnd, hItem) \
  185. (BOOL)SendMessage( \
  186. (hwnd), TLM_SETSELECTION, 0, (LPARAM)(CONST HTLITEM)(hItem) \
  187. )
  188. #define TreeList_Redraw(hwnd) \
  189. (BOOL)SendMessage((hwnd), TLM_REDRAW, 0, 0)
  190. #define TreeList_IsItemExpanded(hwnd, hItem) \
  191. (BOOL)SendMessage( \
  192. (hwnd), TLM_ISITEMEXPANDED, 0, (LPARAM)(CONST HTLITEM)(hItem) \
  193. )
  194. #define TreeList_GetColumnWidth(hwnd, iCol) \
  195. (INT)SendMessage((hwnd), TLM_GETCOLUMNWIDTH, (WPARAM)(int)(iCol), 0)
  196. #define TreeList_SetColumnWidth(hwnd, iCol, cx) \
  197. (BOOL)SendMessage( \
  198. (hwnd), TLM_SETCOLUMNWIDTH, (WPARAM)(int)(iCol), \
  199. MAKELPARAM((cx), 0) \
  200. )
  201. #endif