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.

246 lines
6.7 KiB

  1. /*++
  2. Module Name:
  3. MmcAdmin.cpp
  4. Abstract:
  5. This module contains the part of the declaration for CDfsSnapinResultManager.
  6. --*/
  7. #include "stdafx.h"
  8. #include "DfsGUI.h"
  9. #include "DfsReslt.h"
  10. #include "DfsScope.h" // The CDfsSnapinScopeManager class
  11. STDMETHODIMP CDfsSnapinResultManager :: AddMenuItems
  12. (
  13. IN LPDATAOBJECT i_lpDataObject,
  14. IN LPCONTEXTMENUCALLBACK i_lpContextMenuCallback,
  15. IN LPLONG i_lpInsertionAllowed
  16. )
  17. /*++
  18. Routine Description:
  19. This routine adds the appropriate context menu using the ContextMenuCallback provided.
  20. Arguments:
  21. i_lpDataObject - The dataobject used to identify the node.
  22. i_lpContextMenuCallback - A callback(function pointer) that is used to add the menu items
  23. i_lpInsertionAllowed - Specifies what menus can be added and where they can be added.
  24. --*/
  25. {
  26. RETURN_INVALIDARG_IF_NULL(i_lpDataObject);
  27. RETURN_INVALIDARG_IF_NULL(i_lpContextMenuCallback);
  28. RETURN_INVALIDARG_IF_NULL(i_lpInsertionAllowed);
  29. if (DOBJ_CUSTOMOCX == i_lpDataObject)
  30. return S_OK;
  31. return m_pScopeManager->AddMenuItems(i_lpDataObject, i_lpContextMenuCallback, i_lpInsertionAllowed);
  32. }
  33. STDMETHODIMP
  34. CDfsSnapinResultManager::Command(
  35. IN LONG i_lCommandID,
  36. IN LPDATAOBJECT i_lpDataObject
  37. )
  38. /*++
  39. Routine Description:
  40. Action to be taken on a context menu selection or click is takes place.
  41. Arguments:
  42. i_lpDataObject - The dataobject used to identify the node.
  43. i_lCommandID - The Command ID of the menu for which action has to be taken
  44. --*/
  45. {
  46. RETURN_INVALIDARG_IF_NULL(i_lpDataObject);
  47. return m_pScopeManager->Command(i_lCommandID, i_lpDataObject);
  48. }
  49. STDMETHODIMP
  50. CDfsSnapinResultManager::SetControlbar(
  51. IN LPCONTROLBAR i_pControlbar
  52. )
  53. /*++
  54. Routine Description:
  55. Called by MMC to allow us to set the IControlbar interface pointer
  56. Arguments:
  57. i_pControlbar - The IControlbar interface pointer. Note, can be 0.
  58. --*/
  59. {
  60. if (!i_pControlbar) // We are shutting down
  61. m_pControlbar.Release();
  62. else
  63. m_pControlbar = i_pControlbar;
  64. return S_OK;
  65. }
  66. void
  67. CDfsSnapinResultManager::DetachAllToolbars()
  68. {
  69. if (m_pMMCAdminToolBar)
  70. m_pControlbar->Detach(m_pMMCAdminToolBar);
  71. if (m_pMMCRootToolBar)
  72. m_pControlbar->Detach(m_pMMCRootToolBar);
  73. if (m_pMMCJPToolBar)
  74. m_pControlbar->Detach(m_pMMCJPToolBar);
  75. if (m_pMMCReplicaToolBar)
  76. m_pControlbar->Detach(m_pMMCReplicaToolBar);
  77. }
  78. STDMETHODIMP
  79. CDfsSnapinResultManager::ControlbarNotify(
  80. IN MMC_NOTIFY_TYPE i_Event,
  81. IN LPARAM i_lArg,
  82. IN LPARAM i_lParam
  83. )
  84. /*++
  85. Routine Description:
  86. Called by MMC to notify the toolbar about an event.
  87. This can be selection\disselection of node, click on a toolbar, etc.
  88. Arguments:
  89. i_Event - The event that occurred.
  90. i_lArg - The argument for the event. Depends on the event
  91. i_lParam - The parameter for the event. Depends on the event
  92. --*/
  93. {
  94. HRESULT hr = S_OK;
  95. LPDATAOBJECT p_DataObject = NULL;
  96. CMmcDisplay* pCMmcDisplayObj = NULL;
  97. switch (i_Event) // Decide which method to call of the display object
  98. {
  99. case MMCN_BTN_CLICK: // Click on a toolbar
  100. {
  101. p_DataObject = (LPDATAOBJECT)i_lArg;
  102. // Get the display object from IDataObject
  103. hr = m_pScopeManager->GetDisplayObject(p_DataObject, &pCMmcDisplayObj);
  104. RETURN_IF_FAILED(hr);
  105. // Ask the display object to handle click on the toolbar
  106. hr = pCMmcDisplayObj->ToolbarClick(m_pControlbar, i_lParam);
  107. RETURN_IF_FAILED(hr);
  108. break;
  109. }
  110. case MMCN_SELECT: // A node is being selected\deselected
  111. {
  112. BOOL bSelect = (BOOL) HIWORD(i_lArg);
  113. p_DataObject = (LPDATAOBJECT)i_lParam;
  114. if (DOBJ_CUSTOMOCX == p_DataObject)
  115. break;
  116. // Get the display object from IDataObject
  117. hr = m_pScopeManager->GetDisplayObject(p_DataObject, &pCMmcDisplayObj);
  118. RETURN_IF_FAILED(hr);
  119. // Create the appropriate tool bar if it is
  120. // Not created.
  121. // Then ask the display object to handle selection
  122. //
  123. // Update the custom toolbars.
  124. // On select, it should detach unused toolbars and attach new ones as needed.
  125. // On deselect, to minimize flashing, it should not detach toolbars; it is
  126. // best to disable them, but doing nothing on deselect is also acceptable.
  127. //
  128. DISPLAY_OBJECT_TYPE DisplayObType = pCMmcDisplayObj->GetDisplayObjectType();
  129. switch (DisplayObType)
  130. {
  131. case DISPLAY_OBJECT_TYPE_ADMIN:
  132. if (!m_pMMCAdminToolBar)
  133. {
  134. hr = pCMmcDisplayObj->CreateToolbar(m_pControlbar, (LPEXTENDCONTROLBAR)this, &m_pMMCAdminToolBar);
  135. RETURN_IF_FAILED(hr);
  136. }
  137. if (bSelect)
  138. {
  139. DetachAllToolbars();
  140. m_pControlbar->Attach(TOOLBAR, (LPUNKNOWN) m_pMMCAdminToolBar);
  141. }
  142. hr = pCMmcDisplayObj->ToolbarSelect(i_lArg, m_pMMCAdminToolBar);
  143. break;
  144. case DISPLAY_OBJECT_TYPE_ROOT:
  145. if (!m_pMMCRootToolBar)
  146. {
  147. hr = pCMmcDisplayObj->CreateToolbar(m_pControlbar, (LPEXTENDCONTROLBAR)this, &m_pMMCRootToolBar);
  148. RETURN_IF_FAILED(hr);
  149. }
  150. if (bSelect)
  151. {
  152. DetachAllToolbars();
  153. m_pControlbar->Attach(TOOLBAR, (LPUNKNOWN) m_pMMCRootToolBar);
  154. }
  155. hr = pCMmcDisplayObj->ToolbarSelect(i_lArg, m_pMMCRootToolBar);
  156. break;
  157. case DISPLAY_OBJECT_TYPE_JUNCTION:
  158. if (!m_pMMCJPToolBar)
  159. {
  160. hr = pCMmcDisplayObj->CreateToolbar(m_pControlbar, (LPEXTENDCONTROLBAR)this, &m_pMMCJPToolBar);
  161. RETURN_IF_FAILED(hr);
  162. }
  163. if (bSelect)
  164. {
  165. DetachAllToolbars();
  166. m_pControlbar->Attach(TOOLBAR, (LPUNKNOWN) m_pMMCJPToolBar);
  167. }
  168. hr = pCMmcDisplayObj->ToolbarSelect(i_lArg, m_pMMCJPToolBar);
  169. break;
  170. case DISPLAY_OBJECT_TYPE_REPLICA:
  171. if (!m_pMMCReplicaToolBar)
  172. {
  173. hr = pCMmcDisplayObj->CreateToolbar(m_pControlbar, (LPEXTENDCONTROLBAR)this, &m_pMMCReplicaToolBar);
  174. RETURN_IF_FAILED(hr);
  175. }
  176. if (bSelect)
  177. {
  178. DetachAllToolbars();
  179. m_pControlbar->Attach(TOOLBAR, (LPUNKNOWN) m_pMMCReplicaToolBar);
  180. }
  181. hr = pCMmcDisplayObj->ToolbarSelect(i_lArg, m_pMMCReplicaToolBar);
  182. break;
  183. }
  184. break;
  185. }
  186. default:
  187. break;
  188. } // switch()
  189. return hr;
  190. }