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.

234 lines
9.0 KiB

  1. /*++
  2. Copyright (c) 1994-95 Microsoft Corporation
  3. Module Name:
  4. utils.h
  5. Abstract:
  6. Utilities.
  7. Author:
  8. Don Ryan (donryan) 04-Jan-1995
  9. Environment:
  10. User Mode - Win32
  11. Revision History:
  12. Jeff Parham (jeffparh) 16-Jan-1996
  13. Added new element to LV_COLUMN_ENTRY to differentiate the string
  14. used for the column header from the string used in the menus
  15. (so that the menu option can contain hot keys).
  16. --*/
  17. #ifndef _UTILS_H_
  18. #define _UTILS_H_
  19. #define LPSTR_TEXTCALLBACK_MAX 260
  20. //
  21. // List view utilities
  22. //
  23. #define LVID_SEPARATOR 0
  24. #define LVID_UNSORTED_LIST -1
  25. typedef struct _LV_COLUMN_ENTRY {
  26. int iSubItem; // column index
  27. int nStringId; // header string id
  28. int nMenuStringId; // menu option string id
  29. int nRelativeWidth; // header width
  30. } LV_COLUMN_ENTRY, *PLV_COLUMN_ENTRY;
  31. #pragma warning(disable:4200)
  32. typedef struct _LV_COLUMN_INFO {
  33. BOOL bSortOrder; // sort order (ascending false)
  34. int nSortedItem; // column sorted (default none)
  35. int nColumns;
  36. LV_COLUMN_ENTRY lvColumnEntry[];
  37. } LV_COLUMN_INFO, *PLV_COLUMN_INFO;
  38. #pragma warning(default:4200)
  39. void LvInitColumns(CListCtrl* pListCtrl, PLV_COLUMN_INFO plvColumnInfo);
  40. void LvResizeColumns(CListCtrl* pListCtrl, PLV_COLUMN_INFO plvColumnInfo);
  41. void LvChangeFormat(CListCtrl* pListCtrl, UINT nFormatId);
  42. LPVOID LvGetSelObj(CListCtrl* pListCtrl);
  43. LPVOID LvGetNextObj(CListCtrl* pListCtrl, LPINT piItem, int nType = LVNI_ALL|LVNI_SELECTED);
  44. void LvSelObjIfNecessary(CListCtrl* pListCtrl, BOOL bSetFocus = FALSE);
  45. BOOL LvInsertObArray(CListCtrl* pListCtrl, PLV_COLUMN_INFO plvColumnInfo, CObArray* pObArray);
  46. BOOL LvRefreshObArray(CListCtrl* pListCtrl, PLV_COLUMN_INFO plvColumnInfo, CObArray* pObArray);
  47. void LvReleaseObArray(CListCtrl* pListCtrl);
  48. void LvReleaseSelObjs(CListCtrl* pListCtrl);
  49. #ifdef _DEBUG
  50. void LvDumpObArray(CListCtrl* pListCtrl);
  51. #endif
  52. //
  53. // Tree view utilites
  54. //
  55. typedef struct _TV_EXPANDED_ITEM {
  56. HTREEITEM hItem;
  57. CCmdTarget* pObject;
  58. } TV_EXPANDED_ITEM, *PTV_EXPANDED_ITEM;
  59. typedef struct _TV_EXPANDED_INFO {
  60. int nExpandedItems;
  61. TV_EXPANDED_ITEM* pExpandedItems;
  62. } TV_EXPANDED_INFO, *PTV_EXPANDED_INFO;
  63. LPVOID TvGetSelObj(CTreeCtrl* pTreeCtrl);
  64. BOOL TvInsertObArray(CTreeCtrl* pTreeCtrl, HTREEITEM hParent, CObArray* pObArray, BOOL bIsContainer = TRUE);
  65. BOOL TvRefreshObArray(CTreeCtrl* pTreeCtrl, HTREEITEM hParent, CObArray* pObArray, TV_EXPANDED_INFO* pExpandedInfo, BOOL bIsContainer = TRUE);
  66. void TvReleaseObArray(CTreeCtrl* pTreeCtrl, HTREEITEM hParent);
  67. long TvSizeObArray(CTreeCtrl* pTreeCtrl, HTREEITEM hParent);
  68. HTREEITEM TvGetDomain(CTreeCtrl* pTreeCtrl, HTREEITEM hParent, CCmdTarget* pObject);
  69. HTREEITEM TvGetServer(CTreeCtrl* pTreeCtrl, HTREEITEM hParent, CCmdTarget* pObject);
  70. HTREEITEM TvGetService(CTreeCtrl* pTreeCtrl, HTREEITEM hParent, CCmdTarget* pObject);
  71. void TvSwitchItem(CTreeCtrl* pTreeCtrl, HTREEITEM hItem, TV_EXPANDED_ITEM* pExpandedItem);
  72. //
  73. // Tab control utilities
  74. //
  75. #define TCE_LISTVIEW 0x10000000
  76. #define TCE_TREEVIEW 0x20000000
  77. #define TCE_MASK_CONTROL 0xF0000000
  78. #define IsListView(pte) ((pte)->dwFlags & TCE_LISTVIEW)
  79. #define IsTreeView(pte) ((pte)->dwFlags & TCE_TREEVIEW)
  80. #define IsItemSelectedInList(plv) (::LvGetSelObj((CListCtrl*)(plv)) != NULL)
  81. #define IsItemSelectedInTree(ptv) (::TvGetSelObj((CTreeCtrl*)(ptv)) != NULL)
  82. #define IsItemSelected(pte) ((IsListView(pte)) ? (IsItemSelectedInList((pte)->pWnd)) : (IsItemSelectedInTree((pte)->pWnd)))
  83. #define TCE_FORMAT_LARGE_ICONS 0x01000000
  84. #define TCE_FORMAT_SMALL_ICONS 0x02000000
  85. #define TCE_FORMAT_LIST 0x04000000
  86. #define TCE_FORMAT_REPORT 0x08000000
  87. #define TCE_MASK_FORMAT 0x0F000000
  88. #define IsFormatLargeIcons(pte) ((pte)->dwFlags & TCE_FORMAT_LARGE_ICONS)
  89. #define IsFormatSmallIcons(pte) ((pte)->dwFlags & TCE_FORMAT_SMALL_ICONS)
  90. #define IsFormatList(pte) ((pte)->dwFlags & TCE_FORMAT_LIST)
  91. #define IsFormatReport(pte) ((pte)->dwFlags & TCE_FORMAT_REPORT)
  92. #define SetFormatLargeIcons(pte) {(pte)->dwFlags = ((pte)->dwFlags & ~TCE_MASK_FORMAT) | TCE_FORMAT_LARGE_ICONS;}
  93. #define SetFormatSmallIcons(pte) {(pte)->dwFlags = ((pte)->dwFlags & ~TCE_MASK_FORMAT) | TCE_FORMAT_SMALL_ICONS;}
  94. #define SetFormatList(pte) {(pte)->dwFlags = ((pte)->dwFlags & ~TCE_MASK_FORMAT) | TCE_FORMAT_LIST;}
  95. #define SetFormatReport(pte) {(pte)->dwFlags = ((pte)->dwFlags & ~TCE_MASK_FORMAT) | TCE_FORMAT_REPORT;}
  96. #define TCE_SUPPORTS_FORMAT 0x00010000
  97. #define TCE_SUPPORTS_DELETE 0x00020000
  98. #define TCE_SUPPORTS_EDIT 0x00040000
  99. #define TCE_SUPPORTS_SORT 0x00080000
  100. #define TCE_SUPPORTS_ALL 0x00FF0000
  101. #define TCE_MASK_OPTIONS 0x00FF0000
  102. #define IsFormatSupported(pte) ((pte)->dwFlags & TCE_SUPPORTS_FORMAT)
  103. #define IsDeleteSupported(pte) ((pte)->dwFlags & TCE_SUPPORTS_DELETE)
  104. #define IsEditSupported(pte) ((pte)->dwFlags & TCE_SUPPORTS_EDIT)
  105. #define IsSortSupported(pte) ((pte)->dwFlags & TCE_SUPPORTS_SORT)
  106. #define TCE_STATUS_TAB_UPDATED 0x00000001
  107. #define TCE_STATUS_TAB_IN_FOCUS 0x00000002
  108. #define TCE_MASK_STATUS 0x0000FFFF
  109. #define IsTabUpdated(pte) ((pte)->dwFlags & TCE_STATUS_TAB_UPDATED)
  110. #define IsTabInFocus(pte) ((pte)->dwFlags & TCE_STATUS_TAB_IN_FOCUS)
  111. #define SetTabUpdated(pte) {(pte)->dwFlags = ((pte)->dwFlags & ~TCE_MASK_STATUS) | TCE_STATUS_TAB_UPDATED;}
  112. #define SetTabInFocus(pte) {(pte)->dwFlags = ((pte)->dwFlags & ~TCE_MASK_STATUS) | TCE_STATUS_TAB_IN_FOCUS;}
  113. #define ClrTabUpdated(pte) {(pte)->dwFlags &= ~TCE_STATUS_TAB_UPDATED;}
  114. #define ClrTabInFocus(pte) {(pte)->dwFlags &= ~TCE_STATUS_TAB_IN_FOCUS;}
  115. #define UPDATE_INFO_LICENSES 0x00000001
  116. #define UPDATE_INFO_PRODUCTS 0x00000002
  117. #define UPDATE_INFO_GROUPS 0x00000004
  118. #define UPDATE_INFO_USERS 0x00000008
  119. #define UPDATE_INFO_SERVERS 0x00000010
  120. #define UPDATE_INFO_SERVICES 0x00000020
  121. #define UPDATE_INFO_ALL 0x000000FF
  122. #define UPDATE_INFO_NONE 0x00000000
  123. #define UPDATE_INFO_ABORT 0x80000000
  124. #define UPDATE_INFO_CLIENTS (UPDATE_INFO_USERS | UPDATE_INFO_GROUPS)
  125. #define IsUpdateAborted(flg) ((DWORD)(flg) & UPDATE_INFO_ABORT)
  126. #define IsLicenseInfoUpdated(flg) ((DWORD)(flg) & UPDATE_INFO_LICENSES)
  127. #define IsProductInfoUpdated(flg) ((DWORD)(flg) & UPDATE_INFO_PRODUCTS)
  128. #define IsGroupInfoUpdated(flg) ((DWORD)(flg) & UPDATE_INFO_GROUPS)
  129. #define IsUserInfoUpdated(flg) ((DWORD)(flg) & UPDATE_INFO_USERS)
  130. #define IsServerInfoUpdated(flg) ((DWORD)(flg) & UPDATE_INFO_SERVERS)
  131. #define IsServiceInfoUpdated(flg) ((DWORD)(flg) & UPDATE_INFO_SERVICES)
  132. #define UPDATE_MAIN_TABS (UPDATE_INFO_CLIENTS | UPDATE_INFO_PRODUCTS | UPDATE_INFO_LICENSES)
  133. #define UPDATE_BROWSER_TAB (UPDATE_INFO_SERVERS)
  134. #define UPDATE_DOMAIN_SELECTED (UPDATE_INFO_ALL)
  135. #define UPDATE_LICENSE_ADDED (UPDATE_INFO_CLIENTS | UPDATE_INFO_PRODUCTS | UPDATE_INFO_LICENSES)
  136. #define UPDATE_LICENSE_DELETED (UPDATE_INFO_CLIENTS | UPDATE_INFO_PRODUCTS | UPDATE_INFO_LICENSES)
  137. #define UPDATE_LICENSE_REVOKED (UPDATE_INFO_CLIENTS | UPDATE_INFO_PRODUCTS)
  138. #define UPDATE_LICENSE_UPGRADED (UPDATE_INFO_CLIENTS | UPDATE_INFO_PRODUCTS)
  139. #define UPDATE_LICENSE_MODE (UPDATE_INFO_SERVICES| UPDATE_INFO_PRODUCTS)
  140. #define UPDATE_GROUP_ADDED (UPDATE_INFO_CLIENTS | UPDATE_INFO_PRODUCTS)
  141. #define UPDATE_GROUP_DELETED (UPDATE_INFO_CLIENTS | UPDATE_INFO_PRODUCTS)
  142. #define UPDATE_GROUP_ALTERED (UPDATE_INFO_CLIENTS | UPDATE_INFO_PRODUCTS)
  143. typedef struct _TC_TAB_ENTRY {
  144. int iItem;
  145. int nStringId;
  146. DWORD dwFlags;
  147. CWnd* pWnd;
  148. PLV_COLUMN_INFO plvColumnInfo; // only valid for listview...
  149. } TC_TAB_ENTRY, *PTC_TAB_ENTRY;
  150. #pragma warning(disable:4200)
  151. typedef struct _TC_TAB_INFO {
  152. int nTabs;
  153. TC_TAB_ENTRY tcTabEntry[];
  154. } TC_TAB_INFO, *PTC_TAB_INFO;
  155. #pragma warning(default:4200)
  156. void TcInitTabs(CTabCtrl* pTabCtrl, PTC_TAB_INFO ptcTabInfo);
  157. //
  158. // Other stuff...
  159. //
  160. void SetDefaultFont(CWnd* pWnd);
  161. void SafeEnableWindow(CWnd* pEnableWnd, CWnd* pNewFocusWnd, CWnd* pOldFocusWnd, BOOL bEnableWnd);
  162. double SecondsSince1980ToDate(unsigned long dwSeconds);
  163. #ifdef _DEBUG
  164. #define VALIDATE_OBJECT(pOb, ObClass) \
  165. { ASSERT_VALID((pOb)); ASSERT((pOb)->IsKindOf(RUNTIME_CLASS(ObClass))); }
  166. #else
  167. #define VALIDATE_OBJECT(pOb, ObClass)
  168. #endif
  169. #endif // _UTILS_H_