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.

239 lines
6.4 KiB

  1. // ActionManScopeItem.cpp: implementation of the CActionManScopeItem class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. #include "stdafx.h"
  5. #include "snapin.h"
  6. #include "ActionManScopeItem.h"
  7. #include "ActionManResultsView.h"
  8. #include "ActionPolicyScopeItem.h"
  9. #ifdef _DEBUG
  10. #undef THIS_FILE
  11. static char THIS_FILE[]=__FILE__;
  12. #define new DEBUG_NEW
  13. #endif
  14. // {6751D765-CAA3-11d2-BD8E-0000F87A3912}
  15. static GUID GUID_ActionMan =
  16. { 0x6751d765, 0xcaa3, 0x11d2, { 0xbd, 0x8e, 0x0, 0x0, 0xf8, 0x7a, 0x39, 0x12 } };
  17. IMPLEMENT_DYNCREATE(CActionManScopeItem,CHMScopeItem)
  18. //////////////////////////////////////////////////////////////////////
  19. // Construction/Destruction
  20. //////////////////////////////////////////////////////////////////////
  21. CActionManScopeItem::CActionManScopeItem()
  22. {
  23. m_lpguidItemType = &GUID_ActionMan;
  24. }
  25. CActionManScopeItem::~CActionManScopeItem()
  26. {
  27. Destroy();
  28. }
  29. //////////////////////////////////////////////////////////////////////
  30. // Creation Members
  31. //////////////////////////////////////////////////////////////////////
  32. bool CActionManScopeItem::Create(CScopePane* pScopePane, CScopePaneItem* pParentItem)
  33. {
  34. TRACEX(_T("CActionManScopeItem::Create\n"));
  35. TRACEARGn(pScopePane);
  36. TRACEARGn(pParentItem);
  37. // set up all the icons first
  38. m_IconResIds.Add(IDI_ICON_ACTIONMAN);
  39. m_OpenIconResIds.Add(IDI_ICON_ACTIONMAN);
  40. SetIconIndex(0);
  41. SetOpenIconIndex(0);
  42. // call base class Create method
  43. if( ! CScopePaneItem::Create(pScopePane,pParentItem) )
  44. {
  45. TRACE(_T("CScopePaneItem::Create failed.\n"));
  46. return false;
  47. }
  48. // set display names
  49. CString sName;
  50. sName.LoadString(IDS_STRING_ACTIONMAN);
  51. SetDisplayName(0,sName);
  52. // add a few random action policies
  53. CActionPolicyScopeItem* pItem = new CActionPolicyScopeItem;
  54. pItem->Create(GetScopePane(),this);
  55. pItem->SetDisplayName(0,_T("Default Action List"));
  56. m_Children.Add(pItem);
  57. // add a few random action policies
  58. pItem = new CActionPolicyScopeItem;
  59. pItem->Create(GetScopePane(),this);
  60. pItem->SetDisplayName(0,_T("Console Action List"));
  61. m_Children.Add(pItem);
  62. pItem = new CActionPolicyScopeItem;
  63. pItem->Create(GetScopePane(),this);
  64. pItem->SetDisplayName(0,_T("Action List 1"));
  65. m_Children.Add(pItem);
  66. pItem = new CActionPolicyScopeItem;
  67. pItem->Create(GetScopePane(),this);
  68. pItem->SetDisplayName(0,_T("Action List 2"));
  69. m_Children.Add(pItem);
  70. pItem = new CActionPolicyScopeItem;
  71. pItem->Create(GetScopePane(),this);
  72. pItem->SetDisplayName(0,_T("Action List 3"));
  73. m_Children.Add(pItem);
  74. return true;
  75. }
  76. //////////////////////////////////////////////////////////////////////
  77. // Results Pane View Members
  78. //////////////////////////////////////////////////////////////////////
  79. CResultsPaneView* CActionManScopeItem::CreateResultsPaneView()
  80. {
  81. TRACEX(_T("CActionManScopeItem::CreateResultsPaneView\n"));
  82. return new CActionManResultsView;
  83. }
  84. //////////////////////////////////////////////////////////////////////
  85. // MMC Notify Handlers
  86. //////////////////////////////////////////////////////////////////////
  87. HRESULT CActionManScopeItem::OnAddMenuItems(LPCONTEXTMENUCALLBACK piCallback,long __RPC_FAR *pInsertionAllowed)
  88. {
  89. TRACEX(_T("CActionManScopeItem::OnAddMenuItems\n"));
  90. TRACEARGn(piCallback);
  91. TRACEARGn(pInsertionAllowed);
  92. HRESULT hr = S_OK;
  93. // Add New Menu Items
  94. if( CCM_INSERTIONALLOWED_NEW & *pInsertionAllowed )
  95. {
  96. }
  97. // Add Task Menu Items
  98. if( CCM_INSERTIONALLOWED_TASK & *pInsertionAllowed )
  99. {
  100. CONTEXTMENUITEM cmi;
  101. CString sResString;
  102. CString sResString2;
  103. sResString.LoadString(IDS_STRING_CLEAR_EVENTS);
  104. cmi.strName = LPTSTR(LPCTSTR(sResString));
  105. sResString2.LoadString(IDS_STRING_CLEAR_EVENTS_DESCRIPTION);
  106. cmi.strStatusBarText = LPTSTR(LPCTSTR(sResString2));
  107. cmi.lCommandID = IDM_CLEAR_EVENTS;
  108. cmi.lInsertionPointID = CCM_INSERTIONPOINTID_PRIMARY_TASK;
  109. cmi.fFlags = 0;
  110. cmi.fSpecialFlags = 0;
  111. hr = piCallback->AddItem(&cmi);
  112. if( !SUCCEEDED(hr) )
  113. {
  114. TRACE(_T("FAILED : IContextMenuCallback::AddItem failed.\n"));
  115. return hr;
  116. }
  117. // separator
  118. cmi.strName = NULL;
  119. cmi.strStatusBarText = NULL;
  120. cmi.lCommandID = NULL;
  121. cmi.lInsertionPointID = CCM_INSERTIONPOINTID_PRIMARY_TASK;
  122. cmi.fFlags = MF_SEPARATOR;
  123. cmi.fSpecialFlags = 0;
  124. hr = piCallback->AddItem(&cmi);
  125. if( !SUCCEEDED(hr) )
  126. {
  127. TRACE(_T("FAILED : IContextMenuCallback::AddItem failed.\n"));
  128. return hr;
  129. }
  130. }
  131. // Add View Menu Items
  132. if( CCM_INSERTIONALLOWED_VIEW & *pInsertionAllowed )
  133. {
  134. CONTEXTMENUITEM cmi;
  135. CString sResString;
  136. CString sResString2;
  137. sResString.LoadString(IDS_STRING_STATUS_ONLY);
  138. cmi.strName = LPTSTR(LPCTSTR(sResString));
  139. sResString2.LoadString(IDS_STRING_STATUS_ONLY_DESCRIPTION);
  140. cmi.strStatusBarText = LPTSTR(LPCTSTR(sResString2));
  141. cmi.lCommandID = IDM_STATUS_ONLY;
  142. cmi.lInsertionPointID = CCM_INSERTIONPOINTID_PRIMARY_VIEW;
  143. cmi.fFlags = MF_UNCHECKED;
  144. cmi.fSpecialFlags = 0;
  145. hr = piCallback->AddItem(&cmi);
  146. if( !SUCCEEDED(hr) )
  147. {
  148. TRACE(_T("FAILED : IContextMenuCallback::AddItem failed.\n"));
  149. return hr;
  150. }
  151. sResString.LoadString(IDS_STRING_ICONS_STATUS);
  152. cmi.strName = LPTSTR(LPCTSTR(sResString));
  153. sResString2.LoadString(IDS_STRING_ICONS_STATUS_DESCRIPTION);
  154. cmi.strStatusBarText = LPTSTR(LPCTSTR(sResString2));
  155. cmi.lCommandID = IDM_ICONS_WITH_STATUS;
  156. cmi.lInsertionPointID = CCM_INSERTIONPOINTID_PRIMARY_VIEW;
  157. cmi.fFlags = MF_CHECKED;
  158. cmi.fSpecialFlags = 0;
  159. hr = piCallback->AddItem(&cmi);
  160. if( !SUCCEEDED(hr) )
  161. {
  162. TRACE(_T("FAILED : IContextMenuCallback::AddItem failed.\n"));
  163. return hr;
  164. }
  165. // icon legend
  166. sResString.LoadString(IDS_STRING_ICON_LEGEND);
  167. cmi.strName = LPTSTR(LPCTSTR(sResString));
  168. sResString2.LoadString(IDS_STRING_ICON_LEGEND_DESCRIPTION);
  169. cmi.strStatusBarText = LPTSTR(LPCTSTR(sResString2));
  170. cmi.lCommandID = IDM_ICON_LEGEND;
  171. cmi.lInsertionPointID = CCM_INSERTIONPOINTID_PRIMARY_VIEW;
  172. cmi.fFlags = 0;
  173. cmi.fSpecialFlags = 0;
  174. hr = piCallback->AddItem(&cmi);
  175. if( !SUCCEEDED(hr) )
  176. {
  177. TRACE(_T("FAILED : IContextMenuCallback::AddItem failed.\n"));
  178. return hr;
  179. }
  180. }
  181. return hr;
  182. }
  183. HRESULT CActionManScopeItem::OnCommand(long lCommandID)
  184. {
  185. TRACEX(_T("CActionManScopeItem::OnCommand\n"));
  186. TRACEARGn(lCommandID);
  187. HRESULT hr = S_OK;
  188. switch(lCommandID)
  189. {
  190. case IDM_CLEAR_EVENTS:
  191. {
  192. }
  193. break;
  194. }
  195. return hr;
  196. }