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.

194 lines
5.2 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name:
  4. faxcconbar.cpp
  5. Abstract:
  6. This file contains my implementation of IExtendControlbar for IComponent.
  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. // CFaxComponentExtendContextMenu - IExtendContextMenu implementation for IComponent
  31. //
  32. //
  33. HRESULT
  34. STDMETHODCALLTYPE
  35. CFaxComponentExtendControlbar::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: CFaxComponentExtendControlbar::SetControlbar") ));
  47. assert(m_pFaxComponent != NULL );
  48. if( m_pFaxComponent == NULL ) {
  49. return E_UNEXPECTED;
  50. }
  51. if( pControlbar == NULL ) {
  52. DebugPrint(( TEXT(" ********************* FREE Controlbar") ));
  53. if( m_pFaxComponent->m_pControlbar != NULL ) {
  54. m_pFaxComponent->m_pControlbar->Release();
  55. m_pFaxComponent->m_pControlbar = NULL;
  56. }
  57. } else {
  58. DebugPrint(( TEXT(" ********************* SET Controlbar") ));
  59. // should only be called once??
  60. assert( m_pFaxComponent->m_pControlbar == NULL );
  61. m_pFaxComponent->m_pControlbar = pControlbar;
  62. m_pFaxComponent->m_pControlbar->AddRef();
  63. }
  64. return S_OK;
  65. }
  66. HRESULT
  67. STDMETHODCALLTYPE
  68. CFaxComponentExtendControlbar::ControlbarNotify(
  69. IN MMC_NOTIFY_TYPE event,
  70. IN LPARAM arg,
  71. IN LPARAM param)
  72. /*++
  73. Routine Description:
  74. Dispatch the ControbarNotify call to the correct node by extracting the
  75. cookie from the DataObject.
  76. Arguments:
  77. event - the event type.
  78. arg, param - the arguments of the event.
  79. Return Value:
  80. HRESULT indicating SUCCEEDED() or FAILED()
  81. --*/
  82. {
  83. DebugPrint(( TEXT("Trace: CFaxComponentExtendControlbar::ControlbarNotify") ));
  84. CFaxDataObject * myDataObject = NULL;
  85. LONG_PTR cookie = NULL;
  86. HRESULT hr;
  87. if( event == MMCN_BTN_CLICK ) {
  88. ATLTRACE(_T("CFaxComponentExtendControlbar::ControlbarNotify: MMCN_BTN_CLICK\n"));
  89. assert( arg != NULL );
  90. if( arg == NULL ) {
  91. return E_POINTER;
  92. }
  93. myDataObject = ::ExtractOwnDataObject( (LPDATAOBJECT)arg );
  94. assert( myDataObject != NULL );
  95. if( myDataObject == NULL ) {
  96. return E_UNEXPECTED;
  97. }
  98. cookie = myDataObject->GetCookie();
  99. if( cookie == NULL ) {
  100. // root
  101. hr = m_pFaxComponent->pOwner->globalRoot->ControlBarOnBtnClick( m_pFaxComponent, myDataObject, param );
  102. } else {
  103. // child
  104. try {
  105. hr = ((CInternalNode *)cookie)->ControlBarOnBtnClick( m_pFaxComponent, myDataObject, param );
  106. } catch ( ... ) {
  107. DebugPrint(( TEXT("Invalid Cookie: 0x%08x"), cookie ));
  108. assert( FALSE ); // got passed an INVALID COOKIE!?!?!?!?
  109. hr = E_UNEXPECTED;
  110. }
  111. }
  112. } else if( event == MMCN_SELECT ) {
  113. ATLTRACE(_T("CFaxComponentExtendControlbar::ControlbarNotify: MMCN_SELECT\n"));
  114. assert( param != NULL );
  115. if( param == NULL ) {
  116. return E_POINTER;
  117. }
  118. #ifdef DEBUG
  119. if( HIWORD( arg ) == TRUE ) {
  120. DebugPrint(( TEXT(" +++++++++++ ControlbarNotify Select") ));
  121. } else {
  122. DebugPrint(( TEXT(" ----------- ControlbarNotify DESelect") ));
  123. }
  124. #endif
  125. myDataObject = ::ExtractOwnDataObject( (LPDATAOBJECT)param );
  126. assert( myDataObject != NULL );
  127. if( myDataObject == NULL ) {
  128. return E_UNEXPECTED;
  129. }
  130. cookie = myDataObject->GetCookie();
  131. if( cookie == NULL ) {
  132. // root
  133. hr = m_pFaxComponent->pOwner->globalRoot->ControlBarOnSelect( m_pFaxComponent, arg, myDataObject );
  134. } else {
  135. // child
  136. try {
  137. hr = ((CInternalNode *)cookie)->ControlBarOnSelect( m_pFaxComponent, arg, myDataObject );
  138. } catch ( ... ) {
  139. DebugPrint(( TEXT("Invalid Cookie: 0x%08x"), cookie ));
  140. assert( FALSE ); // got passed an INVALID COOKIE!?!?!?!?
  141. hr = E_UNEXPECTED;
  142. }
  143. }
  144. }
  145. return hr;
  146. }