Source code of Windows XP (NT5)
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.

327 lines
9.0 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1997.
  5. //
  6. // File: A D V C F G P . H
  7. //
  8. // Contents: Private header for Advanced Configuration dialog
  9. //
  10. // Notes:
  11. //
  12. // Author: danielwe 20 Nov 1997
  13. //
  14. //----------------------------------------------------------------------------
  15. #pragma once
  16. #include "nsbase.h"
  17. #include "ncatlps.h"
  18. #include "netcfgx.h"
  19. #include "resource.h"
  20. //
  21. // image state entries
  22. //
  23. enum SELS_MASKS
  24. {
  25. SELS_CHECKED = 0x1,
  26. SELS_UNCHECKED = 0x2,
  27. SELS_FIXEDBINDING_DISABLED = 0x3,
  28. SELS_FIXEDBINDING_ENABLED = 0x4,
  29. };
  30. enum MAB_DIRECTION
  31. {
  32. MAB_UP = 1,
  33. MAB_DOWN = 2,
  34. };
  35. class CSortableBindPath;
  36. typedef list<CSortableBindPath> SBP_LIST;
  37. enum ASSOCIATE_FLAGS
  38. {
  39. ASSCF_ON_ENABLE = 0x1,
  40. ASSCF_ON_DISABLE = 0x2,
  41. ASSCF_ANCESTORS = 0x8,
  42. };
  43. struct BIND_PATH_INFO
  44. {
  45. INetCfgBindingPath * pncbp;
  46. DWORD dwLength;
  47. };
  48. typedef list<BIND_PATH_INFO *> BPIP_LIST;
  49. typedef list<INetCfgComponent *> NCC_LIST;
  50. typedef list<INetCfgBindingPath *> NCBP_LIST;
  51. struct TREE_ITEM_DATA
  52. {
  53. INetCfgComponent * pncc;
  54. BPIP_LIST listbpipOnEnable;
  55. BPIP_LIST listbpipOnDisable;
  56. BOOL fOrdered;
  57. };
  58. struct HTREEITEMP
  59. {
  60. HTREEITEM hti;
  61. };
  62. typedef list<HTREEITEMP> HTI_LIST;
  63. //
  64. // CBindingsDlg
  65. //
  66. class CBindingsDlg: public CPropSheetPage
  67. {
  68. BEGIN_MSG_MAP(CBindingsDlg)
  69. MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
  70. MESSAGE_HANDLER(WM_CONTEXTMENU, OnContextMenu)
  71. MESSAGE_HANDLER(WM_HELP, OnHelp)
  72. NOTIFY_CODE_HANDLER(PSN_APPLY, OnOk)
  73. COMMAND_ID_HANDLER(PSB_Adapter_Up, OnAdapterUp)
  74. COMMAND_ID_HANDLER(PSB_Adapter_Down, OnAdapterDown)
  75. COMMAND_ID_HANDLER(PSB_Binding_Up, OnBindingUp)
  76. COMMAND_ID_HANDLER(PSB_Binding_Down, OnBindingDown)
  77. NOTIFY_CODE_HANDLER(TVN_DELETEITEM, OnTreeDeleteItem)
  78. NOTIFY_CODE_HANDLER(TVN_KEYDOWN, OnTreeKeyDown)
  79. NOTIFY_CODE_HANDLER(TVN_ITEMEXPANDING, OnTreeItemExpanding)
  80. NOTIFY_CODE_HANDLER(TVN_SELCHANGED, OnTreeItemChanged)
  81. NOTIFY_CODE_HANDLER(LVN_DELETEITEM, OnListDeleteItem)
  82. NOTIFY_CODE_HANDLER(LVN_ITEMCHANGED, OnListItemChanged)
  83. NOTIFY_CODE_HANDLER(NM_DBLCLK, OnDoubleClick)
  84. NOTIFY_CODE_HANDLER(NM_CLICK, OnClick)
  85. END_MSG_MAP()
  86. enum {IDD = IDD_Advanced_Config};
  87. CBindingsDlg(INetCfg *pnc)
  88. {
  89. AddRefObj(m_pnc = pnc);
  90. m_hiconUpArrow = NULL;
  91. m_hiconDownArrow = NULL;
  92. m_iItemSel = -1;
  93. m_hilItemIcons = NULL;
  94. m_hilCheckIcons = NULL;
  95. m_fWanBindingsFirst = FALSE;
  96. }
  97. ~CBindingsDlg();
  98. BOOL FShowPage()
  99. {
  100. return TRUE;
  101. }
  102. private:
  103. INetCfg * m_pnc;
  104. HWND m_hwndLV;
  105. HWND m_hwndTV;
  106. HICON m_hiconUpArrow;
  107. HICON m_hiconDownArrow;
  108. HIMAGELIST m_hilItemIcons;
  109. HIMAGELIST m_hilCheckIcons;
  110. INT m_iItemSel;
  111. BOOL m_fWanBindingsFirst;
  112. INT m_nIndexLan;
  113. //
  114. // Message handlers
  115. //
  116. LRESULT OnInitDialog(UINT uMsg, WPARAM wParam,
  117. LPARAM lParam, BOOL& bHandled);
  118. LRESULT OnContextMenu(UINT uMsg, WPARAM wParam,
  119. LPARAM lParam, BOOL& bHandled);
  120. LRESULT OnHelp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  121. LRESULT OnOk(int idCtrl, LPNMHDR pnmh, BOOL& bHandled);
  122. LRESULT OnAdapterUp(WORD wNotifyCode, WORD wID, HWND hWndCtl,
  123. BOOL& bHandled);
  124. LRESULT OnAdapterDown(WORD wNotifyCode, WORD wID, HWND hWndCtl,
  125. BOOL& bHandled);
  126. LRESULT OnBindingUp(WORD wNotifyCode, WORD wID, HWND hWndCtl,
  127. BOOL& bHandled);
  128. LRESULT OnBindingDown(WORD wNotifyCode, WORD wID, HWND hWndCtl,
  129. BOOL& bHandled);
  130. VOID OnAdapterUpDown(BOOL fUp);
  131. LRESULT OnListItemChanged(int idCtrl, LPNMHDR pnmh, BOOL& bHandled);
  132. LRESULT OnTreeItemChanged(int idCtrl, LPNMHDR pnmh, BOOL& bHandled);
  133. LRESULT OnTreeDeleteItem(int idCtrl, LPNMHDR pnmh, BOOL& fHandled);
  134. LRESULT OnListDeleteItem(int idCtrl, LPNMHDR pnmh, BOOL& fHandled);
  135. LRESULT OnTreeItemExpanding(int idCtrl, LPNMHDR pnmh, BOOL& fHandled);
  136. LRESULT OnTreeKeyDown(int idCtrl, LPNMHDR pnmh, BOOL& fHandled);
  137. LRESULT OnClick(int idCtrl, LPNMHDR pnmh, BOOL& fHandled);
  138. LRESULT OnDoubleClick(int idCtrl, LPNMHDR pnmh, BOOL& fHandled);
  139. //
  140. // Adapter list functions
  141. //
  142. VOID OnAdapterChange(INT iItem);
  143. HRESULT HrBuildAdapterList(VOID);
  144. HRESULT HrGetAdapters(INetCfgComponent *pncc, NCC_LIST *plistNcc);
  145. VOID SetAdapterButtons();
  146. VOID AddListViewItem(INetCfgComponent *pncc, INT ipos, INT nIndex,
  147. PCWSTR pszConnName);
  148. BOOL FIsWanBinding(INT iItem);
  149. VOID GetWanOrdering(VOID);
  150. VOID SetWanOrdering(VOID);
  151. //
  152. // Bindings tree functions
  153. //
  154. VOID SetCheckboxStates(VOID);
  155. VOID ToggleCheckbox(HTREEITEM hti);
  156. VOID OnBindingUpDown(BOOL fUp);
  157. HRESULT HrOrderSubItems(VOID);
  158. HRESULT HrOrderDisableLists(VOID);
  159. HRESULT HrOrderDisableList(TREE_ITEM_DATA *ptid);
  160. HTREEITEM HtiMoveTreeItemAfter(HTREEITEM htiParent, HTREEITEM htiDest,
  161. HTREEITEM htiSrc);
  162. VOID BuildBindingsList(INetCfgComponent *pncc);
  163. HRESULT HrHandleSubpath(SBP_LIST &listsbp, INetCfgBindingPath *pncbpSub);
  164. HRESULT HrHandleSubItem(INetCfgBindingPath *pncbpThis,
  165. INetCfgBindingPath *pncbpMatch,
  166. TREE_ITEM_DATA *ptid,
  167. HTREEITEM htiMatchItem);
  168. HRESULT HrHandleValidSubItem(INetCfgBindingPath *pncbpThis,
  169. INetCfgBindingPath *pncbpMatch,
  170. INetCfgComponent *pnccThisOwner,
  171. HTREEITEM htiMatchItem,
  172. TREE_ITEM_DATA *ptid);
  173. HRESULT HrHandleTopLevel(INetCfgBindingPath *pncbpSub);
  174. HRESULT HrComponentIsHidden(INetCfgBindingPath *pncbp, DWORD iComp);
  175. HTREEITEM HtiAddTreeViewItem(INetCfgComponent * pnccOwner,
  176. HTREEITEM htiParent);
  177. VOID AssociateBinding(INetCfgBindingPath *pncbpThis, HTREEITEM hti,
  178. DWORD dwFlags);
  179. HTREEITEM HtiIsSubItem(INetCfgComponent *pncc, HTREEITEM hti);
  180. VOID MoveAdapterBindings(INetCfgComponent *pnccSrc,
  181. INetCfgComponent *pnccDst,
  182. MAB_DIRECTION mabDir);
  183. LRESULT OnClickOrDoubleClick(int idCtrl, LPNMHDR pnmh, BOOL fDoubleClick);
  184. };
  185. DWORD
  186. GetDepthSpecialCase (
  187. INetCfgBindingPath* pPath);
  188. class CSortableBindPath
  189. {
  190. public:
  191. CSortableBindPath()
  192. {
  193. AssertSzH(FALSE,"Don't use this constructor!");
  194. }
  195. CSortableBindPath(INetCfgBindingPath *pncbp)
  196. {
  197. m_pncbp = pncbp;
  198. }
  199. bool operator<(const CSortableBindPath &refsbp) const;
  200. VOID GetDepth(DWORD *pdwDepth) const
  201. {
  202. *pdwDepth = GetDepthSpecialCase (m_pncbp);
  203. }
  204. INetCfgBindingPath *GetPath() const
  205. {
  206. return m_pncbp;
  207. }
  208. private:
  209. INetCfgBindingPath * m_pncbp;
  210. };
  211. class CIterTreeView
  212. {
  213. public:
  214. CIterTreeView(HWND hwndTV)
  215. {
  216. m_hwndTV = hwndTV;
  217. Reset();
  218. }
  219. HTREEITEM HtiNext();
  220. VOID Reset()
  221. {
  222. HTREEITEM hti;
  223. EraseAndDeleteAll();
  224. hti = TreeView_GetRoot(m_hwndTV);
  225. if (hti)
  226. {
  227. HTREEITEMP htip = {hti};
  228. m_stackHti.push_front(htip);
  229. }
  230. }
  231. HTREEITEM Front()
  232. {
  233. HTREEITEMP htip;
  234. if (m_stackHti.empty())
  235. {
  236. return NULL;
  237. }
  238. htip = m_stackHti.front();
  239. return htip.hti;
  240. }
  241. VOID PopAndDelete()
  242. {
  243. m_stackHti.pop_front();
  244. }
  245. VOID PushAndAlloc(HTREEITEM hti)
  246. {
  247. AssertSzH(hti, "Pushing NULL? Shame on you!");
  248. HTREEITEMP htip = {hti};
  249. m_stackHti.push_front(htip);
  250. }
  251. VOID EraseAndDeleteAll()
  252. {
  253. while (!m_stackHti.empty())
  254. {
  255. PopAndDelete();
  256. }
  257. }
  258. private:
  259. HWND m_hwndTV;
  260. HTI_LIST m_stackHti;
  261. };
  262. BOOL FIsHidden(INetCfgComponent *pncc);
  263. BOOL FDontExposeLower(INetCfgComponent *pncc);
  264. VOID AddToListIfNotAlreadyAdded(BPIP_LIST &bpipList, BIND_PATH_INFO *pbpi);
  265. VOID FreeBindPathInfoList(BPIP_LIST &listbpip);
  266. HRESULT HrCountDontExposeLower(INetCfgBindingPath *pncbp, DWORD *pcItems);
  267. BOOL FEqualComponents(INetCfgComponent *pnccA, INetCfgComponent *pnccB);
  268. VOID ChangeTreeItemParam(HWND hwndTV, HTREEITEM hitem, LPARAM lparam);
  269. BIND_PATH_INFO *BpiFindBindPathInList(INetCfgBindingPath *pncbp,
  270. BPIP_LIST &listBpip);
  271. VOID ChangeListItemParam(HWND hwndLV, INT iItem, LPARAM lParam);
  272. #ifdef ENABLETRACE
  273. VOID DbgDumpBindPath(INetCfgBindingPath *pncbp);
  274. VOID DbgDumpTreeViewItem(HWND hwndTV, HTREEITEM hti);
  275. #else
  276. #define DbgDumpBindPath(x)
  277. #define DbgDumpTreeViewItem(x,y)
  278. #endif