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.

180 lines
4.5 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name:
  4. faxconbar.cpp
  5. Abstract:
  6. This file contains my implementation of IExtendControlbar for IComponentData.
  7. Environment:
  8. WIN32 User Mode
  9. Author:
  10. Darwin Ouyang (t-darouy) 30-Sept-1997
  11. --*/
  12. // faxconbar.cpp : Implementation of CFaxExtendControlbar
  13. #include "stdafx.h"
  14. #include "faxcconbar.h"
  15. #include "faxadmin.h"
  16. #include "faxsnapin.h"
  17. #include "faxcomp.h"
  18. #include "faxcompd.h"
  19. #include "faxdataobj.h"
  20. #include "faxhelper.h"
  21. #include "faxstrt.h"
  22. #include "iroot.h"
  23. #pragma hdrstop
  24. ////////////////////////////////////////////////////////////////////////////////////////////////////
  25. ////////////////////////////////////////////////////////////////////////////////////////////////////
  26. ////////////////////////////////////////////////////////////////////////////////////////////////////
  27. ////////////////////////////////////////////////////////////////////////////////////////////////////
  28. //
  29. //
  30. // CFaxExtendControlbar - IExtendControlbar implementation for IComponentData
  31. //
  32. //
  33. HRESULT
  34. STDMETHODCALLTYPE
  35. CFaxExtendControlbar::SetControlbar(
  36. IN LPCONTROLBAR pControlbar)
  37. /*++
  38. Routine Description:
  39. Stores the LPCONTROLBAR sent to the snapin.
  40. Arguments:
  41. pControlbar - the LPCONTROLBAR to be set.
  42. Return Value:
  43. HRESULT indicating SUCCEEDED() or FAILED()
  44. --*/
  45. {
  46. DebugPrint(( TEXT("Trace: CFaxExtendControlbar::SetControlbar") ));
  47. assert( pControlbar != NULL );
  48. if( pControlbar == NULL ) {
  49. return E_POINTER;
  50. }
  51. assert(m_pFaxSnapin != NULL );
  52. if( m_pFaxSnapin == NULL ) {
  53. return E_UNEXPECTED;
  54. }
  55. m_pFaxSnapin->m_pControlbar = pControlbar;
  56. m_pFaxSnapin->m_pControlbar->AddRef();
  57. return S_OK;
  58. }
  59. HRESULT
  60. STDMETHODCALLTYPE
  61. CFaxExtendControlbar::ControlbarNotify(
  62. IN MMC_NOTIFY_TYPE event,
  63. IN LPARAM arg,
  64. IN LPARAM param)
  65. /*++
  66. Routine Description:
  67. Dispatch the ControbarNotify call to the correct node by extracting the
  68. cookie from the DataObject.
  69. Arguments:
  70. event - the event type.
  71. arg, param - the arguments of the event.
  72. Return Value:
  73. HRESULT indicating SUCCEEDED() or FAILED()
  74. --*/
  75. {
  76. DebugPrint(( TEXT("Trace: CFaxExtendControlbar::ControlbarNotify") ));
  77. CFaxDataObject * myDataObject = NULL;
  78. LONG_PTR cookie = NULL;
  79. HRESULT hr;
  80. if( event == MMCN_BTN_CLICK ) {
  81. ATLTRACE(_T("CFaxExtendControlbar::ControlbarNotify: MMCN_BTN_CLICK\n"));
  82. assert( arg != NULL );
  83. if( arg == NULL ) {
  84. return E_POINTER;
  85. }
  86. myDataObject = ::ExtractOwnDataObject( (LPDATAOBJECT)arg );
  87. assert( myDataObject != NULL );
  88. if( myDataObject == NULL ) {
  89. return E_UNEXPECTED;
  90. }
  91. cookie = myDataObject->GetCookie();
  92. if( cookie == NULL ) {
  93. // root
  94. hr = m_pFaxSnapin->globalRoot->ControlBarOnBtnClick2( m_pFaxSnapin, myDataObject, param );
  95. } else {
  96. // child
  97. try {
  98. hr = ((CInternalNode *)cookie)->ControlBarOnBtnClick2( m_pFaxSnapin, myDataObject, param );
  99. } catch ( ... ) {
  100. DebugPrint(( TEXT("Invalid Cookie: 0x%08x"), cookie ));
  101. assert( FALSE ); // got passed an INVALID COOKIE!?!?!?!?
  102. hr = E_UNEXPECTED;
  103. }
  104. }
  105. } else if( event == MMCN_SELECT ) {
  106. ATLTRACE(_T("CFaxExtendControlbar::ControlbarNotify: MMCN_SELECT\n"));
  107. assert( param != NULL );
  108. if( param == NULL ) {
  109. return E_POINTER;
  110. }
  111. myDataObject = ::ExtractOwnDataObject( (LPDATAOBJECT)param );
  112. assert( myDataObject != NULL );
  113. if( myDataObject == NULL ) {
  114. return E_UNEXPECTED;
  115. }
  116. cookie = myDataObject->GetCookie();
  117. if( cookie == NULL ) {
  118. // root
  119. hr = m_pFaxSnapin->globalRoot->ControlBarOnSelect2( m_pFaxSnapin, arg, myDataObject );
  120. } else {
  121. // child
  122. try {
  123. hr = ((CInternalNode *)cookie)->ControlBarOnSelect2( m_pFaxSnapin, arg, myDataObject );
  124. } catch ( ... ) {
  125. DebugPrint(( TEXT("Invalid Cookie: 0x%08x"), cookie ));
  126. assert( FALSE ); // got passed an INVALID COOKIE!?!?!?!?
  127. hr = E_UNEXPECTED;
  128. }
  129. }
  130. }
  131. return hr;
  132. }