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.

184 lines
5.2 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name:
  4. faxcconmn.cpp
  5. Abstract:
  6. This file contains my implementation of IExtendContextMenu for IComponent.
  7. Environment:
  8. WIN32 User Mode
  9. Author:
  10. Darwin Ouyang (t-darouy) 30-Sept-1997
  11. --*/
  12. // faxconmenu.cpp : Implementation of CFaxExtendContextMenu
  13. #include "stdafx.h"
  14. #include "faxcconmn.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. // CFaxExtendContextMenu implementation
  31. //
  32. //
  33. HRESULT
  34. STDMETHODCALLTYPE
  35. CFaxComponentExtendContextMenu::AddMenuItems(
  36. IN LPDATAOBJECT piDataObject,
  37. IN LPCONTEXTMENUCALLBACK piCallback,
  38. IN OUT long __RPC_FAR *pInsertionAllowed)
  39. /*++
  40. Routine Description:
  41. This routine dispatches AddMenuItems to the correct node by using the
  42. cookie stored in piDataObject.
  43. Arguments:
  44. piDataObject - the data object associated with the target node
  45. piCallback - the CONTEXTMENUCALLBACK used to add items
  46. pInsertionAllowed - flags to allow insertion
  47. Return Value:
  48. HRESULT indicating SUCCEEDED() or FAILED()
  49. --*/
  50. {
  51. DebugPrint(( TEXT("Trace: CFaxComponentExtendContextMenu::AddMenuItems") ));
  52. CFaxDataObject * myDataObject = NULL;
  53. LONG_PTR cookie;
  54. HRESULT hr;
  55. assert( piDataObject != NULL );
  56. if( piDataObject == NULL ) {
  57. return E_POINTER;
  58. }
  59. if( piCallback == NULL ) {
  60. return E_POINTER;
  61. }
  62. if( pInsertionAllowed == NULL ) {
  63. return E_POINTER;
  64. }
  65. myDataObject = ExtractOwnDataObject( piDataObject );
  66. if( myDataObject == NULL ) {
  67. return E_UNEXPECTED;
  68. }
  69. cookie = myDataObject->GetCookie();
  70. if(cookie == NULL) {
  71. // root node
  72. assert( m_pFaxComponent != NULL );
  73. hr = m_pFaxComponent->pOwner->globalRoot->ComponentContextMenuAddMenuItems( m_pFaxComponent,
  74. myDataObject,
  75. piCallback,
  76. pInsertionAllowed );
  77. } else {
  78. // child node
  79. try {
  80. hr = ((CInternalNode *)cookie)->ComponentContextMenuAddMenuItems( m_pFaxComponent,
  81. myDataObject,
  82. piCallback,
  83. pInsertionAllowed );
  84. } catch ( ... ) {
  85. DebugPrint(( TEXT("Invalid Cookie: 0x%08x"), cookie ));
  86. assert( FALSE ); // got passed an INVALID COOKIE!?!?!?!?
  87. hr = E_UNEXPECTED;
  88. }
  89. }
  90. return hr;
  91. }
  92. HRESULT
  93. STDMETHODCALLTYPE
  94. CFaxComponentExtendContextMenu::Command(
  95. IN long lCommandID,
  96. IN LPDATAOBJECT piDataObject)
  97. /*++
  98. Routine Description:
  99. This routine dispatches context menu commands to the correct node by using the
  100. cookie stored in piDataObject.
  101. Arguments:
  102. lCommandID - the command id
  103. piDataObject - the data object associated with the target node
  104. Return Value:
  105. HRESULT indicating SUCCEEDED() or FAILED()
  106. --*/
  107. {
  108. DebugPrint(( TEXT("Trace: CFaxComponentExtendContextMenu::Command") ));
  109. CFaxDataObject * myDataObject = NULL;
  110. LONG_PTR cookie;
  111. HRESULT hr;
  112. assert( piDataObject != NULL );
  113. if( piDataObject == NULL ) {
  114. return E_POINTER;
  115. }
  116. myDataObject = ExtractOwnDataObject( piDataObject );
  117. if( myDataObject == NULL ) {
  118. return E_UNEXPECTED;
  119. }
  120. cookie = myDataObject->GetCookie();
  121. if(cookie == NULL) {
  122. // root node
  123. assert( m_pFaxComponent != NULL );
  124. hr = m_pFaxComponent->pOwner->globalRoot->ComponentContextMenuCommand( m_pFaxComponent,
  125. lCommandID,
  126. myDataObject );
  127. } else {
  128. // child node
  129. try {
  130. hr = ((CInternalNode *)cookie)->ComponentContextMenuCommand( m_pFaxComponent,
  131. lCommandID,
  132. myDataObject );
  133. } catch ( ... ) {
  134. DebugPrint(( TEXT("Invalid Cookie: 0x%08x"), cookie ));
  135. assert( FALSE ); // got passed an INVALID COOKIE!?!?!?!?
  136. hr = E_UNEXPECTED;
  137. }
  138. }
  139. return hr;
  140. }