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
5.0 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name:
  4. faxconmenu.cpp
  5. Abstract:
  6. This file contains my implementation of IExtendContextMenu.
  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 "faxconmenu.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 - IExtendContextMenu implementation for IComponentData
  31. //
  32. //
  33. HRESULT
  34. STDMETHODCALLTYPE
  35. CFaxExtendContextMenu::AddMenuItems(
  36. IN LPDATAOBJECT piDataObject,
  37. IN LPCONTEXTMENUCALLBACK piCallback,
  38. IN OUT long __RPC_FAR *pInsertionAllowed)
  39. /*++
  40. Routine Description:
  41. Dispatch the AddMenuItems call to the correct node by extracting the
  42. cookie from the DataObject.
  43. Arguments:
  44. piDataObject - the data object for the target node.
  45. piCallback - the CONTEXTMENUCALLBACK pointer
  46. pInsertionAllowed - flags to indicate whether insertion is allowed.
  47. Return Value:
  48. HRESULT indicating SUCCEEDED() or FAILED()
  49. --*/
  50. {
  51. DebugPrint(( TEXT("Trace: CFaxExtendContextMenu::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. hr = m_pFaxSnapin->globalRoot->ComponentDataContextMenuAddMenuItems( m_pFaxSnapin,
  73. myDataObject,
  74. piCallback,
  75. pInsertionAllowed );
  76. } else {
  77. // child node
  78. try {
  79. hr = ((CInternalNode *)cookie)->ComponentDataContextMenuAddMenuItems( m_pFaxSnapin,
  80. myDataObject,
  81. piCallback,
  82. pInsertionAllowed );
  83. } catch (...) {
  84. DebugPrint(( TEXT("Invalid Cookie: 0x%08x"), cookie ));
  85. assert( FALSE ); // got passed an INVALID COOKIE!?!?!?!?
  86. hr = E_UNEXPECTED;
  87. }
  88. }
  89. return hr;
  90. }
  91. HRESULT
  92. STDMETHODCALLTYPE
  93. CFaxExtendContextMenu::Command(
  94. IN long lCommandID,
  95. IN LPDATAOBJECT piDataObject)
  96. /*++
  97. Routine Description:
  98. Dispatch the context menu Command call to the correct node by extracting the
  99. cookie from the DataObject.
  100. Arguments:
  101. lCommandID - the command id
  102. piDataObject - the DataObject for the target node.
  103. Return Value:
  104. HRESULT indicating SUCCEEDED() or FAILED()
  105. --*/
  106. {
  107. DebugPrint(( TEXT("Trace: CFaxExtendContextMenu::Command") ));
  108. CFaxDataObject * myDataObject = NULL;
  109. LONG_PTR cookie;
  110. HRESULT hr;
  111. assert( piDataObject != NULL );
  112. if( piDataObject == NULL ) {
  113. return E_POINTER;
  114. }
  115. myDataObject = ExtractOwnDataObject( piDataObject );
  116. if( myDataObject == NULL ) {
  117. return E_UNEXPECTED;
  118. }
  119. cookie = myDataObject->GetCookie();
  120. if(cookie == NULL) {
  121. // root node
  122. hr = m_pFaxSnapin->globalRoot->ComponentDataContextMenuCommand( m_pFaxSnapin,
  123. lCommandID,
  124. myDataObject );
  125. } else {
  126. // child node
  127. try {
  128. hr = ((CInternalNode *)cookie)->ComponentDataContextMenuCommand( m_pFaxSnapin,
  129. lCommandID,
  130. myDataObject );
  131. } catch ( ... ) {
  132. DebugPrint(( TEXT("Invalid Cookie: 0x%08x"), cookie ));
  133. assert( FALSE ); // got passed an INVALID COOKIE!?!?!?!?
  134. hr = E_UNEXPECTED;
  135. }
  136. }
  137. return hr;
  138. }