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.

144 lines
3.5 KiB

  1. // HMGraphViewEventSink.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "snapin.h"
  5. #include "HMGraphViewEventSink.h"
  6. #include "HMGraphView.h"
  7. #include "SplitPaneResultsView.h"
  8. #ifdef _DEBUG
  9. #define new DEBUG_NEW
  10. #undef THIS_FILE
  11. static char THIS_FILE[] = __FILE__;
  12. #endif
  13. /////////////////////////////////////////////////////////////////////////////
  14. // CHMGraphViewEventSink
  15. IMPLEMENT_DYNCREATE(CHMGraphViewEventSink, CCmdTarget)
  16. CHMGraphViewEventSink::CHMGraphViewEventSink()
  17. {
  18. EnableAutomation();
  19. m_dwEventCookie = 0L;
  20. m_pGraphView = NULL;
  21. m_pView = NULL;
  22. }
  23. CHMGraphViewEventSink::~CHMGraphViewEventSink()
  24. {
  25. m_pGraphView = NULL;
  26. m_pView = NULL;
  27. }
  28. void CHMGraphViewEventSink::OnFinalRelease()
  29. {
  30. // When the last reference for an automation object is released
  31. // OnFinalRelease is called. The base class will automatically
  32. // deletes the object. Add additional cleanup required for your
  33. // object before calling the base class.
  34. CCmdTarget::OnFinalRelease();
  35. }
  36. CSplitPaneResultsView* CHMGraphViewEventSink::GetResultsViewPtr()
  37. {
  38. TRACEX(_T("CHMGraphViewEventSink::GetResultsViewPtr\n"));
  39. if( ! GfxCheckObjPtr(m_pView,CSplitPaneResultsView) )
  40. {
  41. return NULL;
  42. }
  43. return m_pView;
  44. }
  45. void CHMGraphViewEventSink::SetResultsViewPtr(CSplitPaneResultsView* pView)
  46. {
  47. TRACEX(_T("CHMGraphViewEventSink::SetObjectPtr\n"));
  48. TRACEARGn(pView);
  49. if( ! pView || ! GfxCheckObjPtr(pView,CSplitPaneResultsView) )
  50. {
  51. m_pView = NULL;
  52. return;
  53. }
  54. m_pView = pView;
  55. }
  56. HRESULT CHMGraphViewEventSink::HookUpEventSink(LPUNKNOWN lpControlUnknown)
  57. {
  58. TRACEX(_T("CHMGraphViewEventSink::HookUpEventSink\n"));
  59. TRACEARGn(lpControlUnknown);
  60. HRESULT hr = S_OK;
  61. IConnectionPointContainer* pCPC = 0;
  62. hr = lpControlUnknown->QueryInterface(IID_IConnectionPointContainer, (void**)&pCPC);
  63. if(pCPC)
  64. {
  65. IProvideClassInfo2* pPCI = 0;
  66. lpControlUnknown->QueryInterface(IID_IProvideClassInfo2, (void**)&pPCI);
  67. if(pPCI)
  68. {
  69. IID iidEventSet;
  70. hr = pPCI->GetGUID(GUIDKIND_DEFAULT_SOURCE_DISP_IID,&iidEventSet);
  71. if(SUCCEEDED(hr))
  72. {
  73. IConnectionPoint* pCP = 0;
  74. hr = pCPC->FindConnectionPoint(iidEventSet, &pCP);
  75. if(pCP)
  76. {
  77. pCP->Advise(GetIDispatch(TRUE),&m_dwEventCookie);
  78. pCP->Release();
  79. }
  80. }
  81. pPCI->Release();
  82. }
  83. pCPC->Release();
  84. }
  85. return hr;
  86. }
  87. BEGIN_MESSAGE_MAP(CHMGraphViewEventSink, CCmdTarget)
  88. //{{AFX_MSG_MAP(CHMGraphViewEventSink)
  89. // NOTE - the ClassWizard will add and remove mapping macros here.
  90. //}}AFX_MSG_MAP
  91. END_MESSAGE_MAP()
  92. BEGIN_DISPATCH_MAP(CHMGraphViewEventSink, CCmdTarget)
  93. //{{AFX_DISPATCH_MAP(CHMGraphViewEventSink)
  94. DISP_FUNCTION(CHMGraphViewEventSink, "OnChangeStyle", OnChangeStyle, VT_EMPTY, VTS_I4)
  95. //}}AFX_DISPATCH_MAP
  96. END_DISPATCH_MAP()
  97. // Note: we add support for IID_IHMGraphViewEventSink to support typesafe binding
  98. // from VBA. This IID must match the GUID that is attached to the
  99. // dispinterface in the .ODL file.
  100. // {C54EFB01-3555-11D3-BE19-0000F87A3912}
  101. static const IID IID_IHMGraphViewEventSink =
  102. { 0xc54efb01, 0x3555, 0x11d3, { 0xbe, 0x19, 0x0, 0x0, 0xf8, 0x7a, 0x39, 0x12 } };
  103. BEGIN_INTERFACE_MAP(CHMGraphViewEventSink, CCmdTarget)
  104. INTERFACE_PART(CHMGraphViewEventSink, IID_IHMGraphViewEventSink, Dispatch)
  105. END_INTERFACE_MAP()
  106. /////////////////////////////////////////////////////////////////////////////
  107. // CHMGraphViewEventSink message handlers
  108. void CHMGraphViewEventSink::OnChangeStyle(long lNewStyle)
  109. {
  110. CSplitPaneResultsView* pView = GetResultsViewPtr();
  111. if( ! pView )
  112. {
  113. return;
  114. }
  115. pView->OnGraphViewStyleChange(m_pGraphView);
  116. }