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.

701 lines
19 KiB

  1. // ActionScopeItem.cpp: implementation of the CActionScopeItem class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. //
  5. // 03/04/00 v-marfin bug 59643 : Make the details page the default page.
  6. // 04/02/00 v-marfin bug 59643b: Make General Page the first page, but set
  7. // details page as the focus on a new data collector.
  8. //
  9. //
  10. //
  11. //
  12. #include "stdafx.h"
  13. #include "snapin.h"
  14. #include "ResultsPane.h"
  15. #include "ActionScopeItem.h"
  16. #include "ActionResultsView.h"
  17. #include "Action.h"
  18. #include "ActionGeneralPage.h"
  19. #include "ActionCmdLinePage.h"
  20. #include "ActionEmailPage.h"
  21. #include "ActionLogFilePage.h"
  22. #include "ActionNtEventLogPage.h"
  23. #include "ActionPagingPage.h"
  24. #include "ActionScriptPage.h"
  25. #include "ActionSchedulePage.h"
  26. #ifdef _DEBUG
  27. #undef THIS_FILE
  28. static char THIS_FILE[]=__FILE__;
  29. #define new DEBUG_NEW
  30. #endif
  31. // {EF423181-CA9B-11d2-BD8E-0000F87A3912}
  32. static GUID GUID_Action =
  33. { 0xef423181, 0xca9b, 0x11d2, { 0xbd, 0x8e, 0x0, 0x0, 0xf8, 0x7a, 0x39, 0x12 } };
  34. IMPLEMENT_DYNCREATE(CActionScopeItem,CHMScopeItem)
  35. // icon table - associates state to icons
  36. static UINT _Icons[] =
  37. {
  38. // 0 = DEFAULT
  39. IDI_ICON_ACTION,
  40. // 1 = COMMAND LINE
  41. IDI_ICON_ACTION_CMDLINE,
  42. // 2 = EMAIL
  43. IDI_ICON_ACTION_EMAIL,
  44. // 3 = LOGFILE
  45. IDI_ICON_ACTION_LOGFILE,
  46. // 4 = NT EVENT
  47. IDI_ICON_ACTION_NTEVENT,
  48. // 5 = SCRIPT
  49. IDI_ICON_ACTION_SCRIPT,
  50. // 6 = PAGING
  51. IDI_ICON_ACTION_PAGER
  52. };
  53. //////////////////////////////////////////////////////////////////////
  54. // Construction/Destruction
  55. //////////////////////////////////////////////////////////////////////
  56. CActionScopeItem::CActionScopeItem()
  57. {
  58. m_lpguidItemType = &GUID_Action;
  59. }
  60. CActionScopeItem::~CActionScopeItem()
  61. {
  62. Destroy();
  63. }
  64. //////////////////////////////////////////////////////////////////////
  65. // Creation Members
  66. //////////////////////////////////////////////////////////////////////
  67. bool CActionScopeItem::Create(CScopePane* pScopePane, CScopePaneItem* pParentItem)
  68. {
  69. TRACEX(_T("CActionScopeItem::Create\n"));
  70. TRACEARGn(pScopePane);
  71. TRACEARGn(pParentItem);
  72. // set up all the icons first
  73. CAction* pAction = (CAction*)GetObjectPtr();
  74. if( ! GfxCheckObjPtr(pAction,CAction) )
  75. {
  76. return false;
  77. }
  78. int iIconIndex = 0;
  79. switch( pAction->GetType() )
  80. {
  81. case IDM_ACTION_CMDLINE:
  82. {
  83. iIconIndex = 1;
  84. }
  85. break;
  86. case IDM_ACTION_EMAIL:
  87. {
  88. iIconIndex = 2;
  89. }
  90. break;
  91. case IDM_ACTION_LOGFILE:
  92. {
  93. iIconIndex = 3;
  94. }
  95. break;
  96. case IDM_ACTION_NTEVENT:
  97. {
  98. iIconIndex = 4;
  99. }
  100. break;
  101. case IDM_ACTION_SCRIPT:
  102. {
  103. iIconIndex = 5;
  104. }
  105. break;
  106. case IDM_ACTION_PAGING:
  107. {
  108. iIconIndex = 6;
  109. }
  110. break;
  111. default:
  112. {
  113. ASSERT(FALSE);
  114. }
  115. break;
  116. }
  117. m_IconResIds.Add(_Icons[iIconIndex]);
  118. m_OpenIconResIds.Add(_Icons[iIconIndex]);
  119. //------------------------------------------------------------------------------------------------------
  120. // v-marfin : 59492
  121. // Only 1 icon was being loaded above. So any attempt to set a different icon (based on its state for
  122. // example), failed since its index would be out of range.
  123. // Other scope pane items have icons associated with each state they can be in, and they are loaded
  124. // into their m_IconResIds array. When a state changes, the icon at the [state] index is selected.
  125. //
  126. // So here, when we determine the type of action this is (iIconIndex), we will load our own
  127. // m_IconResIds with icons associated with state. This presents one small problem however, the state
  128. // codes do not run in 0,1,2,3,4 etc order, so we have a choice of either just loading the state icons
  129. // and converting the index at SetIconIndex time based on the state, or set just those positions represented
  130. // by the possible states. At this late stage of the game I will choose the latter, not being intimately
  131. // familiar with this system. Can always come back later and change to 1st choice once I am more
  132. // comfortable with the system. For now, fix bugs.
  133. // v-marfin 59492 : Since the icons are handled according to a state code sequence of:
  134. // 0 = good
  135. // 1 = collecting
  136. // 2 = reset
  137. // 3 = info
  138. // 4 = disabled
  139. // 5 = scheduled outage
  140. // 6 = unknown
  141. //
  142. // Set the icon table accordingly. Note that for Actions the only used icons are
  143. // for position 0,4 and 5 so set the other icons to the normal state.
  144. switch( pAction->GetType() )
  145. {
  146. case IDM_ACTION_CMDLINE:
  147. {
  148. // v-marfin 59492
  149. // Forget the preload that went on above...
  150. // First load all the occurrences with the normal icon
  151. for (int x=0;x<7; x++)
  152. {
  153. m_IconResIds.SetAtGrow(x,IDI_ICON_ACTION_CMDLINE);
  154. m_OpenIconResIds.SetAtGrow(x,IDI_ICON_ACTION_CMDLINE);
  155. }
  156. m_IconResIds.SetAtGrow(HMS_DISABLED,IDI_ICON_ACTION_CMDLINE_DISABLED);
  157. m_OpenIconResIds.SetAtGrow(HMS_DISABLED,IDI_ICON_ACTION_CMDLINE_DISABLED);
  158. m_IconResIds.SetAtGrow(HMS_SCHEDULEDOUT,IDI_ICON_ACTION_CMDLINE_OUTAGE);
  159. m_OpenIconResIds.SetAtGrow(HMS_SCHEDULEDOUT,IDI_ICON_ACTION_CMDLINE_OUTAGE);
  160. }
  161. break;
  162. case IDM_ACTION_EMAIL:
  163. {
  164. // v-marfin 59492
  165. // Forget the preload that went on above...
  166. // First load all the occurrences with the normal icon
  167. for (int x=0;x<7; x++)
  168. {
  169. m_IconResIds.SetAtGrow(x,IDI_ICON_ACTION_EMAIL);
  170. m_OpenIconResIds.SetAtGrow(x,IDI_ICON_ACTION_EMAIL);
  171. }
  172. m_IconResIds.SetAtGrow(HMS_DISABLED,IDI_ICON_ACTION_EMAIL_DISABLED);
  173. m_OpenIconResIds.SetAtGrow(HMS_DISABLED,IDI_ICON_ACTION_EMAIL_DISABLED);
  174. m_IconResIds.SetAtGrow(HMS_SCHEDULEDOUT,IDI_ICON_ACTION_EMAIL_OUTAGE);
  175. m_OpenIconResIds.SetAtGrow(HMS_SCHEDULEDOUT,IDI_ICON_ACTION_EMAIL_OUTAGE);
  176. }
  177. break;
  178. case IDM_ACTION_LOGFILE:
  179. {
  180. // v-marfin 59492
  181. // Forget the preload that went on above...
  182. // First load all the occurrences with the normal icon
  183. for (int x=0;x<7; x++)
  184. {
  185. m_IconResIds.SetAtGrow(x,IDI_ICON_ACTION_LOGFILE);
  186. m_OpenIconResIds.SetAtGrow(x,IDI_ICON_ACTION_LOGFILE);
  187. }
  188. m_IconResIds.SetAtGrow(HMS_DISABLED,IDI_ICON_ACTION_LOGFILE_DISABLED);
  189. m_OpenIconResIds.SetAtGrow(HMS_DISABLED,IDI_ICON_ACTION_LOGFILE_DISABLED);
  190. m_IconResIds.SetAtGrow(HMS_SCHEDULEDOUT,IDI_ICON_ACTION_LOGFILE_OUTAGE);
  191. m_OpenIconResIds.SetAtGrow(HMS_SCHEDULEDOUT,IDI_ICON_ACTION_LOGFILE_OUTAGE);
  192. }
  193. break;
  194. case IDM_ACTION_NTEVENT:
  195. {
  196. // v-marfin 59492
  197. // Forget the preload that went on above...
  198. // First load all the occurrences with the normal icon
  199. for (int x=0;x<7; x++)
  200. {
  201. m_IconResIds.SetAtGrow(x,IDI_ICON_ACTION_NTEVENT);
  202. m_OpenIconResIds.SetAtGrow(x,IDI_ICON_ACTION_NTEVENT);
  203. }
  204. m_IconResIds.SetAtGrow(HMS_DISABLED,IDI_ICON_ACTION_NTEVENT_DISABLED);
  205. m_OpenIconResIds.SetAtGrow(HMS_DISABLED,IDI_ICON_ACTION_NTEVENT_DISABLED);
  206. m_IconResIds.SetAtGrow(HMS_SCHEDULEDOUT,IDI_ICON_ACTION_NTEVENT_OUTAGE);
  207. m_OpenIconResIds.SetAtGrow(HMS_SCHEDULEDOUT,IDI_ICON_ACTION_NTEVENT_OUTAGE);
  208. }
  209. break;
  210. case IDM_ACTION_SCRIPT:
  211. {
  212. // v-marfin 59492
  213. // Forget the preload that went on above...
  214. // First load all the occurrences with the normal icon
  215. for (int x=0;x<7; x++)
  216. {
  217. m_IconResIds.SetAtGrow(x,IDI_ICON_ACTION_SCRIPT);
  218. m_OpenIconResIds.SetAtGrow(x,IDI_ICON_ACTION_SCRIPT);
  219. }
  220. m_IconResIds.SetAtGrow(HMS_DISABLED,IDI_ICON_ACTION_SCRIPT_DISABLED);
  221. m_OpenIconResIds.SetAtGrow(HMS_DISABLED,IDI_ICON_ACTION_SCRIPT_DISABLED);
  222. m_IconResIds.SetAtGrow(HMS_SCHEDULEDOUT,IDI_ICON_ACTION_SCRIPT_OUTAGE);
  223. m_OpenIconResIds.SetAtGrow(HMS_SCHEDULEDOUT,IDI_ICON_ACTION_SCRIPT_OUTAGE);
  224. }
  225. break;
  226. case IDM_ACTION_PAGING:
  227. {
  228. // Not using
  229. }
  230. break;
  231. default:
  232. {
  233. ASSERT(FALSE);
  234. }
  235. break;
  236. }
  237. //------------------------------------------------------------------------------------------------------
  238. SetIconIndex(0);
  239. SetOpenIconIndex(0);
  240. // v-marfin: 59492 ---------------------------------------------------------------------------
  241. // Shouldn't this be set to the current state? -------------------------------------
  242. SetIconIndex(GetObjectPtr()->GetState());
  243. SetOpenIconIndex(GetObjectPtr()->GetState());
  244. //--------------------------------------------------------------------------------------------
  245. // call base class Create method
  246. if( ! CScopePaneItem::Create(pScopePane,pParentItem) )
  247. {
  248. TRACE(_T("CScopePaneItem::Create failed.\n"));
  249. return false;
  250. }
  251. // set display names
  252. CString sName;
  253. sName.LoadString(IDS_STRING_ACTION);
  254. SetDisplayName(0,sName);
  255. return true;
  256. }
  257. //////////////////////////////////////////////////////////////////////
  258. // Results Pane View Members
  259. //////////////////////////////////////////////////////////////////////
  260. CResultsPaneView* CActionScopeItem::CreateResultsPaneView()
  261. {
  262. TRACEX(_T("CActionScopeItem::CreateResultsPaneView\n"));
  263. return new CActionResultsView;
  264. }
  265. //////////////////////////////////////////////////////////////////////
  266. // MMC Notify Handlers
  267. //////////////////////////////////////////////////////////////////////
  268. HRESULT CActionScopeItem::OnAddMenuItems(LPCONTEXTMENUCALLBACK piCallback,long __RPC_FAR *pInsertionAllowed)
  269. {
  270. TRACEX(_T("CActionScopeItem::OnAddMenuItems\n"));
  271. TRACEARGn(piCallback);
  272. TRACEARGn(pInsertionAllowed);
  273. HRESULT hr = S_OK;
  274. // Add New Menu Items
  275. if( CCM_INSERTIONALLOWED_NEW & *pInsertionAllowed )
  276. {
  277. }
  278. // Add Task Menu Items
  279. if( CCM_INSERTIONALLOWED_TASK & *pInsertionAllowed )
  280. {
  281. CONTEXTMENUITEM cmi;
  282. CString sResString;
  283. CString sResString2;
  284. // clear events
  285. sResString.LoadString(IDS_STRING_CLEAR_EVENTS);
  286. cmi.strName = LPTSTR(LPCTSTR(sResString));
  287. sResString2.LoadString(IDS_STRING_CLEAR_EVENTS_DESCRIPTION);
  288. cmi.strStatusBarText = LPTSTR(LPCTSTR(sResString2));
  289. cmi.lCommandID = IDM_CLEAR_EVENTS;
  290. cmi.lInsertionPointID = CCM_INSERTIONPOINTID_PRIMARY_TASK;
  291. cmi.fFlags = 0;
  292. cmi.fSpecialFlags = 0;
  293. hr = piCallback->AddItem(&cmi);
  294. if( !SUCCEEDED(hr) )
  295. {
  296. TRACE(_T("FAILED : IContextMenuCallback::AddItem failed.\n"));
  297. return hr;
  298. }
  299. // disable actions
  300. sResString.LoadString(IDS_STRING_DISABLE_ACTIONS);
  301. cmi.strName = LPTSTR(LPCTSTR(sResString));
  302. sResString2.LoadString(IDS_STRING_DISABLE_ACTIONS_DESC);
  303. cmi.strStatusBarText = LPTSTR(LPCTSTR(sResString2));
  304. cmi.lCommandID = IDM_DISABLE_ACTIONS;
  305. cmi.lInsertionPointID = CCM_INSERTIONPOINTID_PRIMARY_TASK;
  306. cmi.fFlags = 0;
  307. cmi.fSpecialFlags = 0;
  308. // v-marfin 59492 : Indicate on menu whether is disabled or not
  309. //------------------------------------------------------------
  310. CHMObject* pObject = GetObjectPtr();
  311. CHMScopeItem* pParentItem = (CHMScopeItem*)GetParent();
  312. // disable menu item if null object ptr or parent is disabled
  313. if( ! pObject || (pParentItem && pParentItem->GetObjectPtr()
  314. && !pParentItem->GetObjectPtr()->IsEnabled()) )
  315. {
  316. cmi.fFlags = MF_DISABLED|MF_GRAYED;
  317. }
  318. else
  319. {
  320. int iState = pObject->IsEnabled();
  321. if( iState == -1 )
  322. {
  323. cmi.fFlags = MF_DISABLED|MF_GRAYED;
  324. }
  325. else if( iState == 0 )
  326. {
  327. cmi.fFlags = MF_CHECKED;
  328. }
  329. else if( iState == 1 )
  330. {
  331. cmi.fFlags = MF_UNCHECKED;
  332. }
  333. }
  334. //------------------------------------------------------------
  335. hr = piCallback->AddItem(&cmi);
  336. if( !SUCCEEDED(hr) )
  337. {
  338. TRACE(_T("FAILED : IContextMenuCallback::AddItem failed.\n"));
  339. return hr;
  340. }
  341. // separator
  342. cmi.strName = NULL;
  343. cmi.strStatusBarText = NULL;
  344. cmi.lCommandID = NULL;
  345. cmi.lInsertionPointID = CCM_INSERTIONPOINTID_PRIMARY_TASK;
  346. cmi.fFlags = MF_SEPARATOR;
  347. cmi.fSpecialFlags = 0;
  348. hr = piCallback->AddItem(&cmi);
  349. if( !SUCCEEDED(hr) )
  350. {
  351. TRACE(_T("FAILED : IContextMenuCallback::AddItem failed.\n"));
  352. return hr;
  353. }
  354. }
  355. // Add View Menu Items
  356. if( CCM_INSERTIONALLOWED_VIEW & *pInsertionAllowed )
  357. {
  358. CONTEXTMENUITEM cmi;
  359. CString sResString;
  360. CString sResString2;
  361. sResString.LoadString(IDS_STRING_STATUS_ONLY);
  362. cmi.strName = LPTSTR(LPCTSTR(sResString));
  363. sResString2.LoadString(IDS_STRING_STATUS_ONLY_DESCRIPTION);
  364. cmi.strStatusBarText = LPTSTR(LPCTSTR(sResString2));
  365. cmi.lCommandID = IDM_STATUS_ONLY;
  366. cmi.lInsertionPointID = CCM_INSERTIONPOINTID_PRIMARY_VIEW;
  367. cmi.fFlags = MF_UNCHECKED;
  368. cmi.fSpecialFlags = 0;
  369. hr = piCallback->AddItem(&cmi);
  370. if( !SUCCEEDED(hr) )
  371. {
  372. TRACE(_T("FAILED : IContextMenuCallback::AddItem failed.\n"));
  373. return hr;
  374. }
  375. sResString.LoadString(IDS_STRING_ICONS_STATUS);
  376. cmi.strName = LPTSTR(LPCTSTR(sResString));
  377. sResString2.LoadString(IDS_STRING_ICONS_STATUS_DESCRIPTION);
  378. cmi.strStatusBarText = LPTSTR(LPCTSTR(sResString2));
  379. cmi.lCommandID = IDM_ICONS_WITH_STATUS;
  380. cmi.lInsertionPointID = CCM_INSERTIONPOINTID_PRIMARY_VIEW;
  381. cmi.fFlags = MF_CHECKED;
  382. cmi.fSpecialFlags = 0;
  383. hr = piCallback->AddItem(&cmi);
  384. if( !SUCCEEDED(hr) )
  385. {
  386. TRACE(_T("FAILED : IContextMenuCallback::AddItem failed.\n"));
  387. return hr;
  388. }
  389. // icon legend
  390. sResString.LoadString(IDS_STRING_ICON_LEGEND);
  391. cmi.strName = LPTSTR(LPCTSTR(sResString));
  392. sResString2.LoadString(IDS_STRING_ICON_LEGEND_DESCRIPTION);
  393. cmi.strStatusBarText = LPTSTR(LPCTSTR(sResString2));
  394. cmi.lCommandID = IDM_ICON_LEGEND;
  395. cmi.lInsertionPointID = CCM_INSERTIONPOINTID_PRIMARY_VIEW;
  396. cmi.fFlags = 0;
  397. cmi.fSpecialFlags = 0;
  398. hr = piCallback->AddItem(&cmi);
  399. if( !SUCCEEDED(hr) )
  400. {
  401. TRACE(_T("FAILED : IContextMenuCallback::AddItem failed.\n"));
  402. return hr;
  403. }
  404. }
  405. return hr;
  406. }
  407. HRESULT CActionScopeItem::OnCommand(long lCommandID)
  408. {
  409. TRACEX(_T("CActionScopeItem::OnCommand\n"));
  410. TRACEARGn(lCommandID);
  411. HRESULT hr = S_OK;
  412. switch(lCommandID)
  413. {
  414. case IDM_CLEAR_EVENTS:
  415. {
  416. }
  417. break;
  418. case IDM_DISABLE_ACTIONS:
  419. {
  420. CHMObject* pObject = GetObjectPtr();
  421. if( ! pObject )
  422. {
  423. ASSERT(FALSE);
  424. return E_FAIL;
  425. }
  426. if( pObject->IsEnabled() )
  427. {
  428. pObject->Disable();
  429. }
  430. else
  431. {
  432. pObject->Enable();
  433. }
  434. }
  435. break;
  436. default:
  437. {
  438. hr = CHMScopeItem::OnCommand(lCommandID);
  439. }
  440. break;
  441. }
  442. return hr;
  443. }
  444. HRESULT CActionScopeItem::OnCreatePropertyPages(LPPROPERTYSHEETCALLBACK lpProvider, INT_PTR handle)
  445. {
  446. TRACEX(_T("CActionScopeItem::OnCreatePropertyPages\n"));
  447. TRACEARGn(lpProvider);
  448. TRACEARGn(handle);
  449. if( m_pScopePane == NULL )
  450. {
  451. return S_FALSE;
  452. }
  453. HRESULT hr = S_OK;
  454. CAction* pAction = (CAction*)GetObjectPtr();
  455. if( ! GfxCheckObjPtr(pAction,CAction) )
  456. {
  457. return E_FAIL;
  458. }
  459. // v-marfin bug 59643b : Make General Page the first page, but set
  460. // details page as the focus on a new data collector.
  461. CActionGeneralPage* pPage1 = new CActionGeneralPage;
  462. pPage1->SetObjectPtr(pAction);
  463. HPROPSHEETPAGE hPage1 = CreatePropertySheetPage( reinterpret_cast<LPCPROPSHEETPAGE>(&pPage1->m_psp) );
  464. hr = lpProvider->AddPage(hPage1);
  465. switch( pAction->GetType() )
  466. {
  467. case IDM_ACTION_CMDLINE:
  468. {
  469. CActionCmdLinePage* pPage2 = new CActionCmdLinePage;
  470. pPage2->SetObjectPtr(pAction);
  471. HPROPSHEETPAGE hPage2 = CreatePropertySheetPage( reinterpret_cast<LPCPROPSHEETPAGE>(&pPage2->m_psp) );
  472. hr = lpProvider->AddPage(hPage2);
  473. }
  474. break;
  475. case IDM_ACTION_EMAIL:
  476. {
  477. CActionEmailPage* pPage2 = new CActionEmailPage;
  478. pPage2->SetObjectPtr(pAction);
  479. HPROPSHEETPAGE hPage2 = CreatePropertySheetPage( reinterpret_cast<LPCPROPSHEETPAGE>(&pPage2->m_psp) );
  480. hr = lpProvider->AddPage(hPage2);
  481. }
  482. break;
  483. case IDM_ACTION_LOGFILE:
  484. {
  485. CActionLogFilePage* pPage2 = new CActionLogFilePage;
  486. pPage2->SetObjectPtr(pAction);
  487. HPROPSHEETPAGE hPage2 = CreatePropertySheetPage( reinterpret_cast<LPCPROPSHEETPAGE>(&pPage2->m_psp) );
  488. hr = lpProvider->AddPage(hPage2);
  489. }
  490. break;
  491. case IDM_ACTION_NTEVENT:
  492. {
  493. CActionNtEventLogPage* pPage2 = new CActionNtEventLogPage;
  494. pPage2->SetObjectPtr(pAction);
  495. HPROPSHEETPAGE hPage2 = CreatePropertySheetPage( reinterpret_cast<LPCPROPSHEETPAGE>(&pPage2->m_psp) );
  496. hr = lpProvider->AddPage(hPage2);
  497. }
  498. break;
  499. case IDM_ACTION_SCRIPT:
  500. {
  501. CActionScriptPage* pPage2 = new CActionScriptPage;
  502. pPage2->SetObjectPtr(pAction);
  503. HPROPSHEETPAGE hPage2 = CreatePropertySheetPage( reinterpret_cast<LPCPROPSHEETPAGE>(&pPage2->m_psp) );
  504. hr = lpProvider->AddPage(hPage2);
  505. }
  506. break;
  507. case IDM_ACTION_PAGING:
  508. {
  509. CActionPagingPage* pPage2 = new CActionPagingPage;
  510. pPage2->SetObjectPtr(pAction);
  511. HPROPSHEETPAGE hPage2 = CreatePropertySheetPage( reinterpret_cast<LPCPROPSHEETPAGE>(&pPage2->m_psp) );
  512. hr = lpProvider->AddPage(hPage2);
  513. }
  514. break;
  515. default:
  516. {
  517. ASSERT(FALSE);
  518. }
  519. break;
  520. }
  521. CActionSchedulePage* pPage3 = new CActionSchedulePage;
  522. pPage3->SetObjectPtr(pAction);
  523. HPROPSHEETPAGE hPage3 = CreatePropertySheetPage( reinterpret_cast<LPCPROPSHEETPAGE>(&pPage3->m_psp) );
  524. hr = lpProvider->AddPage(hPage3);
  525. return hr;
  526. }
  527. HRESULT CActionScopeItem::OnSelect(CResultsPane* pPane, BOOL bSelected)
  528. {
  529. TRACEX(_T("CActionScopeItem::OnSelect\n"));
  530. TRACEARGn(pPane);
  531. TRACEARGn(bSelected);
  532. if( ! CHECKHRESULT(CHMScopeItem::OnSelect(pPane,bSelected)) )
  533. {
  534. TRACE(_T("FAILED : CHMScopeItem::OnSelect returns failure.\n"));
  535. return E_FAIL;
  536. }
  537. if( ! bSelected ) // we are being de-selected so do not do anything
  538. {
  539. return S_OK;
  540. }
  541. LPCONSOLEVERB lpConsoleVerb = pPane->GetConsoleVerbPtr();
  542. HRESULT hr = lpConsoleVerb->SetVerbState( MMC_VERB_PROPERTIES, ENABLED, TRUE );
  543. if( ! CHECKHRESULT(hr) )
  544. {
  545. TRACE(_T("FAILED : IConsoleVerb::SetVerbState failed.\n"));
  546. lpConsoleVerb->Release();
  547. return hr;
  548. }
  549. hr = lpConsoleVerb->SetDefaultVerb( MMC_VERB_PROPERTIES );
  550. if( ! CHECKHRESULT(hr) )
  551. {
  552. TRACE(_T("FAILED : IConsoleVerb::SetDefaultVerb failed.\n"));
  553. lpConsoleVerb->Release();
  554. return hr;
  555. }
  556. hr = lpConsoleVerb->SetVerbState( MMC_VERB_RENAME, ENABLED, TRUE );
  557. if( ! CHECKHRESULT(hr) )
  558. {
  559. TRACE(_T("FAILED : IConsoleVerb::SetVerbState failed.\n"));
  560. lpConsoleVerb->Release();
  561. return hr;
  562. }
  563. hr = lpConsoleVerb->SetVerbState( MMC_VERB_CUT, ENABLED, TRUE );
  564. if( ! CHECKHRESULT(hr) )
  565. {
  566. TRACE(_T("FAILED : IConsoleVerb::SetVerbState failed.\n"));
  567. lpConsoleVerb->Release();
  568. return hr;
  569. }
  570. hr = lpConsoleVerb->SetVerbState( MMC_VERB_COPY, ENABLED, TRUE );
  571. if( ! CHECKHRESULT(hr) )
  572. {
  573. TRACE(_T("FAILED : IConsoleVerb::SetVerbState failed.\n"));
  574. lpConsoleVerb->Release();
  575. return hr;
  576. }
  577. hr = lpConsoleVerb->SetVerbState( MMC_VERB_PASTE, ENABLED, TRUE );
  578. if( ! CHECKHRESULT(hr) )
  579. {
  580. TRACE(_T("FAILED : IConsoleVerb::SetVerbState failed.\n"));
  581. lpConsoleVerb->Release();
  582. return hr;
  583. }
  584. hr = lpConsoleVerb->SetVerbState( MMC_VERB_DELETE, ENABLED, TRUE );
  585. if( ! CHECKHRESULT(hr) )
  586. {
  587. TRACE(_T("FAILED : IConsoleVerb::SetVerbState failed.\n"));
  588. lpConsoleVerb->Release();
  589. return hr;
  590. }
  591. lpConsoleVerb->Release();
  592. return hr;
  593. }