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.

908 lines
21 KiB

  1. // HealthmonResultsPane.cpp: implementation of the CHealthmonResultsPane class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. #include "stdafx.h"
  5. #include "Snapin.h"
  6. #include "HealthmonResultsPane.h"
  7. #include "splitter1.h"
  8. #include "hmtabview.h"
  9. #include "SystemGroup.h"
  10. #ifdef _DEBUG
  11. #define new DEBUG_NEW
  12. #undef THIS_FILE
  13. static char THIS_FILE[] = __FILE__;
  14. #endif
  15. const IID BASED_CODE IID_DHMListView =
  16. { 0x5116a804, 0xdafc, 0x11d2, { 0xbd, 0xa4, 0, 0, 0xf8, 0x7a, 0x39, 0x12 } };
  17. const IID BASED_CODE IID_DHMTabView =
  18. { 0x4fffc38a, 0x2f1e, 0x11d3, { 0xbe, 0x10, 0, 0, 0xf8, 0x7a, 0x39, 0x12 } };
  19. const IID BASED_CODE IID_DHMGraphView =
  20. { 0x9acb0cf6, 0x2ff0, 0x11d3, { 0xbe, 0x15, 0, 0, 0xf8, 0x7a, 0x39, 0x12 } };
  21. IMPLEMENT_DYNCREATE(CHealthmonResultsPane,CResultsPane)
  22. //////////////////////////////////////////////////////////////////////
  23. // Construction/Destruction
  24. //////////////////////////////////////////////////////////////////////
  25. CHealthmonResultsPane::CHealthmonResultsPane()
  26. {
  27. EnableAutomation();
  28. // To keep the application running as long as an OLE automation
  29. // object is active, the constructor calls AfxOleLockApp.
  30. AfxOleLockApp();
  31. m_hbmpNewSystem = NULL;
  32. m_hbmpClearEvents = NULL;
  33. m_hbmpResetStatus = NULL;
  34. m_hbmpDisable = NULL;
  35. }
  36. CHealthmonResultsPane::~CHealthmonResultsPane()
  37. {
  38. // To terminate the application when all objects created with
  39. // with OLE automation, the destructor calls AfxOleUnlockApp.
  40. AfxOleUnlockApp();
  41. // free the bitmaps
  42. if( m_hbmpNewSystem )
  43. {
  44. DeleteObject(m_hbmpNewSystem);
  45. m_hbmpNewSystem = NULL;
  46. }
  47. if( m_hbmpClearEvents )
  48. {
  49. DeleteObject(m_hbmpClearEvents);
  50. m_hbmpClearEvents = NULL;
  51. }
  52. if( m_hbmpResetStatus )
  53. {
  54. DeleteObject(m_hbmpResetStatus);
  55. m_hbmpResetStatus = NULL;
  56. }
  57. if( m_hbmpDisable )
  58. {
  59. DeleteObject(m_hbmpDisable);
  60. m_hbmpDisable = NULL;
  61. }
  62. }
  63. /////////////////////////////////////////////////////////////////////////////
  64. // Creation/Destruction Overrideable Members
  65. /////////////////////////////////////////////////////////////////////////////
  66. bool CHealthmonResultsPane::OnCreateOcx(LPUNKNOWN pIUnknown)
  67. {
  68. TRACEX(_T("CHealthmonResultsPane::OnCreateOcx\n"));
  69. TRACEARGn(pIUnknown);
  70. if( ! CResultsPane::OnCreateOcx(pIUnknown) )
  71. {
  72. TRACE(_T("FAILED : CResultsPane::OnCreateOcx failed.\n"));
  73. return false;
  74. }
  75. if( ! LoadListControls(pIUnknown) )
  76. {
  77. TRACE(_T("FAILED : CHealthmonResultsPane::LoadListControls failed.\n"));
  78. return false;
  79. }
  80. return true;
  81. }
  82. bool CHealthmonResultsPane::OnDestroy()
  83. {
  84. TRACEX(_T("CHealthmonResultsPane::OnDestroy\n"));
  85. m_DispUpperList.ReleaseDispatch();
  86. m_DispLowerList.ReleaseDispatch();
  87. m_DispStatsList.ReleaseDispatch();
  88. m_DispGraph.ReleaseDispatch();
  89. return CResultsPane::OnDestroy();
  90. }
  91. /////////////////////////////////////////////////////////////////////////////
  92. // Results Item Icon Management
  93. /////////////////////////////////////////////////////////////////////////////
  94. int CHealthmonResultsPane::AddIcon(UINT nIconResID, SplitResultsPane pane)
  95. {
  96. TRACEX(_T("CHealthmonResultsPane::AddIcon\n"));
  97. TRACEARGn(nIconResID);
  98. TRACEARGn(pane);
  99. _DHMListView* pList = NULL;
  100. if( pane == Upper )
  101. {
  102. pList = GetUpperListCtrl();
  103. }
  104. else if( pane == Lower )
  105. {
  106. pList = GetLowerListCtrl();
  107. }
  108. else
  109. {
  110. TRACE(_T("FAILED : The pane to add an icon to has not been specified.\n"));
  111. ASSERT(FALSE);
  112. return -1;
  113. }
  114. if( !pList )
  115. {
  116. TRACE(_T("FAILED : list control has not been initialized.\n"));
  117. return -1;
  118. }
  119. HIMAGELIST hImageList = (HIMAGELIST)pList->GetImageList(LVSIL_SMALL);
  120. CImageList smallimages;
  121. if( hImageList == NULL || hImageList == (HIMAGELIST)-1 )
  122. {
  123. if( ! smallimages.Create(16,16,ILC_COLOR4,1,4) )
  124. {
  125. TRACE(_T("FAILED : CImageList::Create returned false.\n"));
  126. return NULL;
  127. }
  128. #ifndef IA64
  129. pList->SetImageList((long)smallimages.GetSafeHandle(),LVSIL_SMALL);
  130. #endif // IA64
  131. }
  132. else
  133. {
  134. smallimages.Attach(hImageList);
  135. }
  136. // load icon
  137. HICON hIcon = AfxGetApp()->LoadIcon(nIconResID);
  138. if( hIcon == NULL )
  139. {
  140. TRACE(_T("FAILED : Icon with resid=%d not found"),nIconResID);
  141. smallimages.Detach();
  142. return -1;
  143. }
  144. // insert icon into image list
  145. int nIconIndex = smallimages.Add(hIcon);
  146. ASSERT(nIconIndex != -1);
  147. // add resid and index to map
  148. if( pane == Upper )
  149. {
  150. m_UpperIconMap.SetAt(nIconResID,nIconIndex);
  151. }
  152. else if( pane == Lower )
  153. {
  154. m_LowerIconMap.SetAt(nIconResID,nIconIndex);
  155. }
  156. else
  157. {
  158. ASSERT(FALSE);
  159. }
  160. smallimages.Detach();
  161. // return index of newly inserted image
  162. return nIconIndex;
  163. }
  164. int CHealthmonResultsPane::GetIconIndex(UINT nIconResID, SplitResultsPane pane)
  165. {
  166. TRACEX(_T("CHealthmonResultsPane::GetIconIndex\n"));
  167. TRACEARGn(nIconResID);
  168. TRACEARGn(pane);
  169. // check map for an existing id
  170. int nIconIndex = -1;
  171. if( pane == Upper )
  172. {
  173. if( m_UpperIconMap.Lookup(nIconResID,nIconIndex) )
  174. {
  175. // if exists, return index
  176. return nIconIndex;
  177. }
  178. }
  179. else if( pane == Lower )
  180. {
  181. if( m_LowerIconMap.Lookup(nIconResID,nIconIndex) )
  182. {
  183. // if exists, return index
  184. return nIconIndex;
  185. }
  186. }
  187. else
  188. {
  189. ASSERT(FALSE);
  190. }
  191. // does not exist so add icon
  192. nIconIndex = AddIcon(nIconResID,pane);
  193. // if it still does not exist, icon is not in resources
  194. if( nIconIndex != -1 )
  195. return nIconIndex;
  196. TRACE(_T("FAILED : Icon with Resource id=%d could not be loaded.\n"),nIconResID);
  197. return -1;
  198. }
  199. int CHealthmonResultsPane::GetIconCount(SplitResultsPane pane)
  200. {
  201. TRACEX(_T("CHealthmonResultsPane::GetIconCount\n"));
  202. TRACEARGn(pane);
  203. int iCount = 0;
  204. if( pane == Upper )
  205. {
  206. iCount = (int)m_UpperIconMap.GetCount();
  207. }
  208. else if( pane == Lower )
  209. {
  210. iCount = (int)m_LowerIconMap.GetCount();
  211. }
  212. else
  213. {
  214. ASSERT(FALSE);
  215. }
  216. return iCount;
  217. }
  218. void CHealthmonResultsPane::RemoveAllIcons(SplitResultsPane pane)
  219. {
  220. TRACEX(_T("CHealthmonResultsPane::RemoveAllIcons\n"));
  221. TRACEARGn(pane);
  222. _DHMListView* pList = NULL;
  223. if( pane == Upper )
  224. {
  225. pList = GetUpperListCtrl();
  226. }
  227. else if( pane == Lower )
  228. {
  229. pList = GetLowerListCtrl();
  230. }
  231. else
  232. {
  233. TRACE(_T("FAILED : The pane to add an icon to has not been specified.\n"));
  234. ASSERT(FALSE);
  235. return;
  236. }
  237. if( !pList )
  238. {
  239. TRACE(_T("FAILED : list control has not been initialized.\n"));
  240. return;
  241. }
  242. HIMAGELIST hImageList = (HIMAGELIST)pList->GetImageList(LVSIL_SMALL);
  243. CImageList smallimages;
  244. if( hImageList == NULL )
  245. {
  246. TRACE(_T("FAILED : CHMListCtrl::GetImageList returns NULL.\n"));
  247. return;
  248. }
  249. smallimages.Attach(hImageList);
  250. int iImageCount = smallimages.GetImageCount();
  251. for( int i = 0; i < iImageCount; i++ )
  252. {
  253. smallimages.Remove(0);
  254. }
  255. if( pane == Upper )
  256. {
  257. m_UpperIconMap.RemoveAll();
  258. }
  259. else if( pane == Lower )
  260. {
  261. m_LowerIconMap.RemoveAll();
  262. }
  263. smallimages.Detach();
  264. }
  265. /////////////////////////////////////////////////////////////////////////////
  266. // Control bar Members
  267. /////////////////////////////////////////////////////////////////////////////
  268. HRESULT CHealthmonResultsPane::OnSetControlbar(LPCONTROLBAR pIControlbar)
  269. {
  270. TRACEX(_T("CHealthmonResultsPane::OnSetControlbar\n"));
  271. TRACEARGn(pIControlbar);
  272. HRESULT hr = S_OK;
  273. // default behavior simply creates an empty toolbar
  274. // override to add buttons or to disallow creation of a new toolbar
  275. if( pIControlbar )
  276. {
  277. if( ! GfxCheckPtr(pIControlbar,IControlbar) )
  278. {
  279. return E_FAIL;
  280. }
  281. // hold on to that controlbar pointer
  282. pIControlbar->AddRef();
  283. m_pIControlbar = pIControlbar;
  284. // create a new toolbar
  285. LPEXTENDCONTROLBAR lpExtendControlBar = (LPEXTENDCONTROLBAR)GetInterface(&IID_IExtendControlbar);
  286. hr = m_pIControlbar->Create(TOOLBAR,lpExtendControlBar,(LPUNKNOWN*)(&m_pIToolbar));
  287. CString sButtonText;
  288. CString sTooltipText;
  289. // New System Button
  290. sButtonText.LoadString(IDS_STRING_NEW_COMPUTER);
  291. sTooltipText.LoadString(IDS_STRING_NEW_COMPUTER);
  292. MMCBUTTON mb;
  293. mb.nBitmap = 0;
  294. mb.idCommand = IDM_NEW_SYSTEM;
  295. mb.fsState = TBSTATE_ENABLED;
  296. mb.fsType = TBSTYLE_BUTTON;
  297. mb.lpButtonText = (LPTSTR)(LPCTSTR)sButtonText;
  298. mb.lpTooltipText = (LPTSTR)(LPCTSTR)sTooltipText;
  299. m_pIToolbar->AddRef();
  300. // Add the toolbar bitmap
  301. CBitmap NewBitmap;
  302. NewBitmap.LoadBitmap(IDB_BITMAP_NEW_SYSTEM);
  303. m_hbmpNewSystem = (HBITMAP)NewBitmap.Detach();
  304. hr = m_pIToolbar->AddBitmap( 1, m_hbmpNewSystem, 16, 16, RGB(255,0,255) );
  305. ASSERT( SUCCEEDED(hr) );
  306. // Add a button
  307. hr = m_pIToolbar->AddButtons(1, &mb);
  308. ASSERT( SUCCEEDED(hr) );
  309. // Clear Alerts Button
  310. sButtonText.LoadString(IDS_STRING_CLEAR_EVENTS);
  311. sTooltipText.LoadString(IDS_STRING_CLEAR_EVENTS);
  312. mb.nBitmap = 1;
  313. mb.idCommand = IDM_CLEAR_EVENTS;
  314. mb.fsState = TBSTATE_ENABLED;
  315. mb.fsType = TBSTYLE_BUTTON;
  316. mb.lpButtonText = (LPTSTR)(LPCTSTR)sButtonText;
  317. mb.lpTooltipText = (LPTSTR)(LPCTSTR)sTooltipText;
  318. m_pIToolbar->AddRef();
  319. // Add the toolbar bitmap
  320. NewBitmap.LoadBitmap(IDB_BITMAP_CLEAR_EVENTS);
  321. m_hbmpClearEvents = (HBITMAP)NewBitmap.Detach();
  322. hr = m_pIToolbar->AddBitmap( 1, m_hbmpClearEvents, 16, 16, RGB(255,0,255) );
  323. ASSERT( SUCCEEDED(hr) );
  324. // Add a button
  325. hr = m_pIToolbar->AddButtons(1, &mb);
  326. ASSERT( SUCCEEDED(hr) );
  327. // Reset Status Button
  328. sButtonText.LoadString(IDS_STRING_RESET_STATUS);
  329. sTooltipText.LoadString(IDS_STRING_RESET_STATUS);
  330. mb.nBitmap = 2;
  331. mb.idCommand = IDM_RESET_STATUS;
  332. mb.fsState = TBSTATE_ENABLED;
  333. mb.fsType = TBSTYLE_BUTTON;
  334. mb.lpButtonText = (LPTSTR)(LPCTSTR)sButtonText;
  335. mb.lpTooltipText = (LPTSTR)(LPCTSTR)sTooltipText;
  336. m_pIToolbar->AddRef();
  337. // Add the toolbar bitmap
  338. NewBitmap.LoadBitmap(IDB_BITMAP_RESET_STATUS);
  339. m_hbmpResetStatus = (HBITMAP)NewBitmap.Detach();
  340. hr = m_pIToolbar->AddBitmap( 1, m_hbmpResetStatus, 16, 16, RGB(255,0,255) );
  341. ASSERT( SUCCEEDED(hr) );
  342. // Add a button
  343. hr = m_pIToolbar->AddButtons(1, &mb);
  344. ASSERT( SUCCEEDED(hr) );
  345. // Disable Button
  346. sButtonText.LoadString(IDS_STRING_DISABLE);
  347. sTooltipText.LoadString(IDS_STRING_DISABLE);
  348. mb.nBitmap = 3;
  349. mb.idCommand = IDM_DISABLE_MONITORING;
  350. mb.fsState = TBSTATE_ENABLED;
  351. mb.fsType = TBSTYLE_BUTTON;
  352. mb.lpButtonText = (LPTSTR)(LPCTSTR)sButtonText;
  353. mb.lpTooltipText = (LPTSTR)(LPCTSTR)sTooltipText;
  354. m_pIToolbar->AddRef();
  355. // Add the toolbar bitmap
  356. NewBitmap.LoadBitmap(IDB_BITMAP_DISABLE);
  357. m_hbmpDisable = (HBITMAP)NewBitmap.Detach();
  358. hr = m_pIToolbar->AddBitmap( 1, m_hbmpDisable, 16, 16, RGB(255,0,255) );
  359. ASSERT( SUCCEEDED(hr) );
  360. // Add a button
  361. hr = m_pIToolbar->AddButtons(1, &mb);
  362. ASSERT( SUCCEEDED(hr) );
  363. }
  364. else
  365. {
  366. // free the toolbar
  367. if( m_pIToolbar )
  368. {
  369. m_pIToolbar->Release();
  370. m_pIToolbar = NULL;
  371. }
  372. // free the controlbar
  373. if( m_pIControlbar )
  374. {
  375. m_pIControlbar->Release();
  376. m_pIControlbar = NULL;
  377. }
  378. // free the bitmaps
  379. if( m_hbmpNewSystem )
  380. {
  381. DeleteObject(m_hbmpNewSystem);
  382. m_hbmpNewSystem = NULL;
  383. }
  384. if( m_hbmpClearEvents )
  385. {
  386. DeleteObject(m_hbmpClearEvents);
  387. m_hbmpClearEvents = NULL;
  388. }
  389. if( m_hbmpResetStatus )
  390. {
  391. DeleteObject(m_hbmpResetStatus);
  392. m_hbmpResetStatus = NULL;
  393. }
  394. if( m_hbmpDisable )
  395. {
  396. DeleteObject(m_hbmpDisable);
  397. m_hbmpDisable = NULL;
  398. }
  399. }
  400. return hr;
  401. }
  402. HRESULT CHealthmonResultsPane::OnControlbarNotify(MMC_NOTIFY_TYPE event, LPARAM arg, LPARAM param)
  403. {
  404. TRACEX(_T("CHealthmonResultsPane::OnControlbarNotify\n"));
  405. TRACEARGn(event);
  406. TRACEARGn(arg);
  407. TRACEARGn(param);
  408. HRESULT hr = S_OK;
  409. switch( event )
  410. {
  411. case MMCN_BTN_CLICK: // For a Controlbar click, the
  412. switch( param ) // param is the MenuItemID
  413. {
  414. case IDM_NEW_SYSTEM:
  415. {
  416. CHealthmonScopePane* pPane = (CHealthmonScopePane*)GetOwnerScopePane();
  417. CSystemGroup* pASG = pPane->GetAllSystemsGroup();
  418. hr = pASG->GetScopeItem(0)->OnCommand(IDM_NEW_SYSTEM);
  419. }
  420. break;
  421. case IDM_CLEAR_EVENTS:
  422. case IDM_RESET_STATUS:
  423. case IDM_DISABLE_MONITORING:
  424. {
  425. CHealthmonScopePane* pPane = (CHealthmonScopePane*)GetOwnerScopePane();
  426. CScopePaneItem* pSPI = pPane->GetSelectedScopeItem();
  427. if( pSPI )
  428. {
  429. hr = (HRESULT)pSPI->OnCommand((long)param);
  430. }
  431. }
  432. break;
  433. }
  434. break;
  435. }
  436. return hr;
  437. }
  438. //////////////////////////////////////////////////////////////////////
  439. // Splitter Control Members
  440. //////////////////////////////////////////////////////////////////////
  441. _DHMListView* CHealthmonResultsPane::GetUpperListCtrl()
  442. {
  443. TRACEX(_T("CHealthmonResultsPane::GetUpperListCtrl\n"));
  444. if( ! GfxCheckPtr(&m_DispUpperList,_DHMListView) )
  445. {
  446. TRACE(_T("FAILED : The upper list control object is not valid.\n"));
  447. return NULL;
  448. }
  449. if( ! (LPDISPATCH)m_DispUpperList )
  450. {
  451. return NULL;
  452. }
  453. return &m_DispUpperList;
  454. }
  455. CHMListViewEventSink* CHealthmonResultsPane::GetUpperListSink()
  456. {
  457. TRACEX(_T("CHealthmonResultsPane::GetUpperListSink\n"));
  458. if( ! GfxCheckPtr(&m_UpperListSink,CHMListViewEventSink) )
  459. {
  460. TRACE(_T("FAILED : The upper list sink object is not valid.\n"));
  461. return NULL;
  462. }
  463. return &m_UpperListSink;
  464. }
  465. _DHMListView* CHealthmonResultsPane::GetLowerListCtrl()
  466. {
  467. TRACEX(_T("CHealthmonResultsPane::GetLowerListCtrl\n"));
  468. if( ! GfxCheckPtr(&m_DispLowerList,_DHMListView) )
  469. {
  470. TRACE(_T("FAILED : The upper list control object is not valid.\n"));
  471. return NULL;
  472. }
  473. if( ! (LPDISPATCH)m_DispLowerList )
  474. {
  475. return NULL;
  476. }
  477. return &m_DispLowerList;
  478. }
  479. CHMListViewEventSink* CHealthmonResultsPane::GetLowerListSink()
  480. {
  481. TRACEX(_T("CHealthmonResultsPane::GetLowerListSink\n"));
  482. if( ! GfxCheckPtr(&m_LowerListSink,CHMListViewEventSink) )
  483. {
  484. TRACE(_T("FAILED : The lower list sink object is not valid.\n"));
  485. return NULL;
  486. }
  487. return &m_LowerListSink;
  488. }
  489. _DHMListView* CHealthmonResultsPane::GetStatsListCtrl()
  490. {
  491. TRACEX(_T("CHealthmonResultsPane::GetStatsListCtrl\n"));
  492. if( ! GfxCheckPtr(&m_DispStatsList,_DHMListView) )
  493. {
  494. TRACE(_T("FAILED : The upper list control object is not valid.\n"));
  495. return NULL;
  496. }
  497. if( ! (LPDISPATCH)m_DispStatsList )
  498. {
  499. return NULL;
  500. }
  501. return &m_DispStatsList;
  502. }
  503. CHMListViewEventSink* CHealthmonResultsPane::GetStatsListSink()
  504. {
  505. TRACEX(_T("CHealthmonResultsPane::GetStatsListSink\n"));
  506. if( ! GfxCheckPtr(&m_StatsListSink,CHMListViewEventSink) )
  507. {
  508. TRACE(_T("FAILED : The Stats list sink object is not valid.\n"));
  509. return NULL;
  510. }
  511. return &m_StatsListSink;
  512. }
  513. _DHMGraphView* CHealthmonResultsPane::GetGraphViewCtrl()
  514. {
  515. TRACEX(_T("CHealthmonResultsPane::GetGraphViewCtrl\n"));
  516. if( ! GfxCheckPtr(&m_DispGraph,_DHMGraphView) )
  517. {
  518. TRACE(_T("FAILED : The graph control object is not valid.\n"));
  519. return NULL;
  520. }
  521. if( ! m_DispGraph.m_lpDispatch )
  522. {
  523. return NULL;
  524. }
  525. return &m_DispGraph;
  526. }
  527. CHMGraphViewEventSink* CHealthmonResultsPane::GetGraphViewSink()
  528. {
  529. TRACEX(_T("CHealthmonResultsPane::GetGraphViewSink\n"));
  530. if( ! GfxCheckObjPtr(&m_GraphSink,CHMGraphViewEventSink) )
  531. {
  532. TRACE(_T("FAILED : The graph control sink is not valid.\n"));
  533. return NULL;
  534. }
  535. return &m_GraphSink;
  536. }
  537. inline bool CHealthmonResultsPane::LoadListControls(LPUNKNOWN pIUnknown)
  538. {
  539. TRACEX(_T("CHealthmonResultsPane::LoadListControls\n"));
  540. TRACEARGn(pIUnknown);
  541. ASSERT(pIUnknown);
  542. if( pIUnknown == NULL )
  543. {
  544. TRACE(_T("FAILED : pIUnknown is NULL.\n"));
  545. return false;
  546. }
  547. // if the controls are already set up then do not create them again
  548. if( m_DispUpperList && m_DispLowerList && m_DispStatsList )
  549. {
  550. return true;
  551. }
  552. // query for the dispatch interface on the splitter control
  553. LPDISPATCH pIDispatch = NULL;
  554. HRESULT hr = pIUnknown->QueryInterface(IID_IDispatch,(LPVOID*)&pIDispatch);
  555. if( ! CHECKHRESULT(hr) || ! pIDispatch )
  556. {
  557. TRACE(_T("FAILED : IUnknown::QI(IID_IDispatch) failed.\n"));
  558. pIUnknown->Release();
  559. return false;
  560. }
  561. // attach a COleDispatchDriver class to it
  562. _DSplitter DSplitter(pIDispatch);
  563. // create the lower list control
  564. CString sControlID = _T("{5116A806-DAFC-11D2-BDA4-0000F87A3912}");
  565. DSplitter.CreateControl(1,0,(LPCTSTR)sControlID);
  566. LPUNKNOWN lpControlUnknown = DSplitter.GetControlIUnknown(1,0);
  567. if( lpControlUnknown == NULL )
  568. {
  569. return false;
  570. }
  571. // attach event sink to the list
  572. hr = m_LowerListSink.HookUpEventSink(lpControlUnknown);
  573. if( ! CHECKHRESULT(hr) )
  574. {
  575. TRACE(_T("FAILED : Unable to hook up event sink to lower list control.\n"));
  576. lpControlUnknown->Release();
  577. return false;
  578. }
  579. // get main dispatch interface to drive the list
  580. hr = lpControlUnknown->QueryInterface(IID_DHMListView,(LPVOID*)&pIDispatch);
  581. if( ! CHECKHRESULT(hr) || ! pIDispatch )
  582. {
  583. TRACE(_T("FAILED : IUnknown::QI(IID_IDispatch) failed.\n"));
  584. lpControlUnknown->Release();
  585. return false;
  586. }
  587. lpControlUnknown->Release();
  588. // attach the OLE dispatch driver class to IDispatch pointer
  589. m_DispLowerList.AttachDispatch(pIDispatch);
  590. m_LowerListSink.m_pDHMListView = &m_DispLowerList;
  591. m_LowerListSink.m_pHMRP = this;
  592. m_LowerListSink.m_Pane = Lower;
  593. // Make certain that label editing is turned off for the lower list
  594. m_DispLowerList.ModifyListStyle(LVS_EDITLABELS,0,0);
  595. // create the tab view control and add the tabs/controls to it
  596. sControlID = _T("HMTabView.HMTabviewctrl.1");
  597. DSplitter.CreateControl(0,0,(LPCTSTR)sControlID);
  598. lpControlUnknown = DSplitter.GetControlIUnknown(0,0);
  599. if( lpControlUnknown == NULL )
  600. {
  601. return false;
  602. }
  603. hr = lpControlUnknown->QueryInterface(IID_DHMTabView,(LPVOID*)&pIDispatch);
  604. if( ! CHECKHRESULT(hr) || ! pIDispatch )
  605. {
  606. TRACE(_T("FAILED : IUnknown::QI(IID_IDispatch) failed.\n"));
  607. lpControlUnknown->Release();
  608. return false;
  609. }
  610. lpControlUnknown->Release();
  611. _DHMTabView DHMTabview(pIDispatch);
  612. CString sTabTitle;
  613. // Details Listview
  614. sTabTitle.LoadString(IDS_STRING_SUMMARY);
  615. DHMTabview.InsertItem(TCIF_TEXT,0,sTabTitle,-1L,0L);
  616. sControlID = _T("{5116A806-DAFC-11D2-BDA4-0000F87A3912}");
  617. DHMTabview.CreateControl(0,sControlID);
  618. // Statistics ListView
  619. sTabTitle.LoadString(IDS_STRING_STATISTICS);
  620. DHMTabview.InsertItem(TCIF_TEXT,1,sTabTitle,-1L,0L);
  621. sControlID = _T("{5116A806-DAFC-11D2-BDA4-0000F87A3912}");
  622. DHMTabview.CreateControl(1,sControlID);
  623. // GraphView
  624. sTabTitle.LoadString(IDS_STRING_GRAPH);
  625. DHMTabview.InsertItem(TCIF_TEXT,2,sTabTitle,-1L,0L);
  626. sControlID = _T("HMGraphView.HMGraphViewCtrl.1");
  627. DHMTabview.CreateControl(2,sControlID);
  628. // attach dispatch drivers for the newly created tabview controls
  629. lpControlUnknown = DHMTabview.GetControl(0);
  630. if( lpControlUnknown == NULL )
  631. {
  632. return false;
  633. }
  634. // attach event sink to the upper list
  635. hr = m_UpperListSink.HookUpEventSink(lpControlUnknown);
  636. if( ! CHECKHRESULT(hr) )
  637. {
  638. TRACE(_T("FAILED : Unable to hook up event sink to upper list control.\n"));
  639. lpControlUnknown->Release();
  640. return false;
  641. }
  642. hr = lpControlUnknown->QueryInterface(IID_DHMListView,(LPVOID*)&pIDispatch);
  643. if( ! CHECKHRESULT(hr) || ! pIDispatch )
  644. {
  645. TRACE(_T("FAILED : IUnknown::QI(IID_IDispatch) failed.\n"));
  646. lpControlUnknown->Release();
  647. return false;
  648. }
  649. lpControlUnknown->Release();
  650. // attach the OLE dispatch driver class to IDispatch pointer
  651. m_DispUpperList.AttachDispatch(pIDispatch);
  652. m_UpperListSink.m_pDHMListView = &m_DispUpperList;
  653. m_UpperListSink.m_pHMRP = this;
  654. m_UpperListSink.m_Pane = Upper;
  655. // get the stats listview control
  656. lpControlUnknown = DHMTabview.GetControl(1);
  657. if( lpControlUnknown == NULL )
  658. {
  659. return false;
  660. }
  661. // attach event sink to the stats list
  662. hr = m_StatsListSink.HookUpEventSink(lpControlUnknown);
  663. if( ! CHECKHRESULT(hr) )
  664. {
  665. TRACE(_T("FAILED : Unable to hook up event sink to stats list control.\n"));
  666. lpControlUnknown->Release();
  667. return false;
  668. }
  669. hr = lpControlUnknown->QueryInterface(IID_DHMListView,(LPVOID*)&pIDispatch);
  670. if( ! CHECKHRESULT(hr) || ! pIDispatch )
  671. {
  672. TRACE(_T("FAILED : IUnknown::QI(IID_IDispatch) failed.\n"));
  673. lpControlUnknown->Release();
  674. return false;
  675. }
  676. lpControlUnknown->Release();
  677. // attach the OLE dispatch driver class to IDispatch pointer
  678. m_DispStatsList.AttachDispatch(pIDispatch);
  679. m_StatsListSink.m_pDHMListView = &m_DispStatsList;
  680. m_StatsListSink.m_pHMRP = this;
  681. m_StatsListSink.m_Pane = Stats;
  682. // Make certain that label editing is turned off for the stats list
  683. m_DispStatsList.ModifyListStyle(LVS_EDITLABELS,0,0);
  684. // get the GraphView Control
  685. lpControlUnknown = DHMTabview.GetControl(2);
  686. if( lpControlUnknown == NULL )
  687. {
  688. DHMTabview.DeleteItem(2);
  689. return false;
  690. }
  691. // attach event sink to the graph
  692. hr = m_GraphSink.HookUpEventSink(lpControlUnknown);
  693. if( ! CHECKHRESULT(hr) )
  694. {
  695. TRACE(_T("FAILED : Unable to hook up event sink to graph control.\n"));
  696. DHMTabview.DeleteItem(2);
  697. lpControlUnknown->Release();
  698. return false;
  699. }
  700. hr = lpControlUnknown->QueryInterface(IID_DHMGraphView,(LPVOID*)&pIDispatch);
  701. if( ! CHECKHRESULT(hr) || ! pIDispatch )
  702. {
  703. TRACE(_T("FAILED : IUnknown::QI(IID_IDispatch) failed.\n"));
  704. DHMTabview.DeleteItem(2);
  705. lpControlUnknown->Release();
  706. return false;
  707. }
  708. lpControlUnknown->Release();
  709. // attach the OLE dispatch driver class to IDispatch pointer for the GraphView
  710. m_DispGraph.AttachDispatch(pIDispatch);
  711. m_GraphSink.SetGraphViewCtrl(&m_DispGraph);
  712. return true;
  713. }
  714. // {FBBB8DB3-AB34-11d2-BD62-0000F87A3912}
  715. IMPLEMENT_OLECREATE_EX(CHealthmonResultsPane, "SnapIn.ResultsPane",
  716. 0xfbbb8db3, 0xab34, 0x11d2, 0xbd, 0x62, 0x0, 0x0, 0xf8, 0x7a, 0x39, 0x12);
  717. BOOL CHealthmonResultsPane::CHealthmonResultsPaneFactory::UpdateRegistry(BOOL bRegister)
  718. {
  719. if (bRegister)
  720. return AfxOleRegisterServerClass(m_clsid, m_lpszProgID, m_lpszProgID, m_lpszProgID, OAT_DISPATCH_OBJECT);
  721. else
  722. return AfxOleUnregisterClass(m_clsid, m_lpszProgID);
  723. }