Leaked source code of windows server 2003
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.

219 lines
6.4 KiB

  1. #include "priv.h"
  2. #include "dhuihand.h"
  3. #define DM_DOCHOSTUIHANDLER 0
  4. //==========================================================================
  5. // IDocHostUIHandler implementation
  6. //==========================================================================
  7. HRESULT CDocHostUIHandler::ShowContextMenu(DWORD dwID, POINT *ppt, IUnknown *pcmdtReserved, IDispatch *pdispReserved)
  8. {
  9. TraceMsg(DM_DOCHOSTUIHANDLER, "CDOH::ShowContextMenu called");
  10. //
  11. // LATER: WebBand in a DesktBar/BrowserBar needs to hook this event
  12. // to popup a customized context menu.
  13. //
  14. return S_FALSE; // Host did not display any UI.
  15. }
  16. HRESULT CDocHostUIHandler::GetHostInfo(DOCHOSTUIINFO *pInfo)
  17. {
  18. TraceMsg(DM_DOCHOSTUIHANDLER, "CDOH::GetHostInfo called");
  19. // Trident does not initialize it. It's defined as [in] parameter.
  20. #if 0
  21. if (pInfo->cbSize < SIZEOF(DOCHOSTUIINFO)) {
  22. return E_INVALIDARG;
  23. }
  24. #endif
  25. pInfo->cbSize = SIZEOF(DOCHOSTUIINFO);
  26. pInfo->dwFlags = DOCHOSTUIFLAG_BROWSER;
  27. // Disable double buffering if low memory machine.
  28. // if (SHIsLowMemoryMachine(ILMM_IE4))
  29. // pInfo->dwFlags = pInfo->dwFlags | DOCHOSTUIFLAG_DISABLE_OFFSCREEN;
  30. pInfo->dwDoubleClick = DOCHOSTUIDBLCLK_DEFAULT; // default
  31. return S_OK;
  32. }
  33. HRESULT CDocHostUIHandler::ShowUI(
  34. DWORD dwID, IOleInPlaceActiveObject *pActiveObject,
  35. IOleCommandTarget *pCommandTarget, IOleInPlaceFrame *pFrame,
  36. IOleInPlaceUIWindow *pDoc)
  37. {
  38. TraceMsg(DM_DOCHOSTUIHANDLER, "CDOH::ShowUI called");
  39. // Host did not display its own UI. Trident will proceed to display its own.
  40. return S_FALSE;
  41. }
  42. HRESULT CDocHostUIHandler::HideUI(void)
  43. {
  44. TraceMsg(DM_DOCHOSTUIHANDLER, "CDOH::HideUI called");
  45. // This one is paired with ShowUI
  46. return S_FALSE;
  47. }
  48. HRESULT CDocHostUIHandler::UpdateUI(void)
  49. {
  50. TraceMsg(DM_DOCHOSTUIHANDLER, "CDOH::UpdateUI called");
  51. // LATER: Isn't this equivalent to OLECMDID_UPDATECOMMANDS?
  52. return S_FALSE;
  53. }
  54. HRESULT CDocHostUIHandler::EnableModeless(BOOL fEnable)
  55. {
  56. TraceMsg(DM_DOCHOSTUIHANDLER, "CDOH::EnableModeless called");
  57. // Called from the Trident when the equivalent member of its
  58. // IOleInPlaceActiveObject is called by the frame. We don't care
  59. // those cases.
  60. return S_OK;
  61. }
  62. HRESULT CDocHostUIHandler::OnDocWindowActivate(BOOL fActivate)
  63. {
  64. // Called from the Trident when the equivalent member of its
  65. // IOleInPlaceActiveObject is called by the frame. We don't care
  66. // those cases.
  67. return S_OK;
  68. }
  69. HRESULT CDocHostUIHandler::OnFrameWindowActivate(BOOL fActivate)
  70. {
  71. // Called from the Trident when the equivalent member of its
  72. // IOleInPlaceActiveObject is called by the frame. We don't care
  73. // those cases.
  74. return S_OK;
  75. }
  76. HRESULT CDocHostUIHandler::ResizeBorder(
  77. LPCRECT prcBorder, IOleInPlaceUIWindow *pUIWindow, BOOL fRameWindow)
  78. {
  79. // Called from the Trident when the equivalent member of its
  80. // IOleInPlaceActiveObject is called by the frame. We don't care
  81. // those cases.
  82. return S_OK;
  83. }
  84. HRESULT CDocHostUIHandler::TranslateAccelerator(
  85. LPMSG lpMsg, const GUID *pguidCmdGroup, DWORD nCmdID)
  86. {
  87. // Called from the Trident when the equivalent member of its
  88. // IOleInPlaceActiveObject is called by the frame. We don't care
  89. // those cases.
  90. return S_FALSE; // The message was not translated
  91. }
  92. HRESULT CDocHostUIHandler::GetOptionKeyPath(BSTR *pbstrKey, DWORD dw)
  93. {
  94. // Trident will default to its own user options.
  95. *pbstrKey = NULL;
  96. return S_FALSE;
  97. }
  98. HRESULT CDocHostUIHandler::GetDropTarget(IDropTarget *pDropTarget, IDropTarget **ppDropTarget)
  99. {
  100. TraceMsg(DM_DOCHOSTUIHANDLER, "CDOH::GetDropTarget called");
  101. return E_NOTIMPL;
  102. }
  103. HRESULT CDocHostUIHandler::GetAltExternal(IDispatch **ppDisp)
  104. {
  105. HRESULT hr = E_FAIL;
  106. IDocHostUIHandler *pDocHostUIHandler;
  107. IOleObject *pOleObject;
  108. IOleClientSite *pOleClientSite;
  109. *ppDisp = NULL;
  110. // * QI ourselves for a service provider
  111. // * QS for the top level browser's service provider
  112. // * Ask for an IOleObject
  113. // * Ask the IOleObject for an IOleClientSite
  114. // * QI the IOleClientSite for an IDocHostUIHandler
  115. // * Call GetExternal on the IDocHostUIHandler to get the IDispatch
  116. if (SUCCEEDED(IUnknown_QueryServiceForWebBrowserApp(this, IID_PPV_ARG(IOleObject, &pOleObject))))
  117. {
  118. if (SUCCEEDED(pOleObject->GetClientSite(&pOleClientSite)))
  119. {
  120. if (SUCCEEDED(pOleClientSite->QueryInterface(IID_IDocHostUIHandler,
  121. (void **)&pDocHostUIHandler)))
  122. {
  123. hr = pDocHostUIHandler->GetExternal(ppDisp);
  124. pDocHostUIHandler->Release();
  125. }
  126. pOleClientSite->Release();
  127. }
  128. pOleObject->Release();
  129. }
  130. return hr;
  131. }
  132. HRESULT CDocHostUIHandler::GetExternal(IDispatch **ppDisp)
  133. {
  134. TraceMsg(DM_DOCHOSTUIHANDLER, "CDOH::GetExternal called");
  135. HRESULT hr;
  136. if (ppDisp)
  137. {
  138. IDispatch *psuihDisp;
  139. IDispatch *pAltExternalDisp;
  140. *ppDisp = NULL;
  141. GetAltExternal(&pAltExternalDisp);
  142. hr = CShellUIHelper_CreateInstance2((IUnknown **)&psuihDisp, IID_IDispatch,
  143. (IUnknown *)this, pAltExternalDisp);
  144. if (SUCCEEDED(hr))
  145. {
  146. *ppDisp = psuihDisp;
  147. if (pAltExternalDisp)
  148. {
  149. // Don't hold a ref - the ShellUIHelper will do it
  150. pAltExternalDisp->Release();
  151. }
  152. }
  153. else if (pAltExternalDisp)
  154. {
  155. // Couldn't create a ShellUIHelper but we got our host's
  156. // external.
  157. *ppDisp = pAltExternalDisp;
  158. hr = S_OK;
  159. }
  160. }
  161. else
  162. {
  163. hr = E_INVALIDARG;
  164. }
  165. ASSERT((SUCCEEDED(hr) && (*ppDisp)) || (FAILED(hr)));
  166. return hr;
  167. }
  168. HRESULT CDocHostUIHandler::TranslateUrl(DWORD dwTranslate, OLECHAR *pchURLIn, OLECHAR **ppchURLOut)
  169. {
  170. TraceMsg(DM_DOCHOSTUIHANDLER, "CDOH::TranslateUrl called");
  171. return S_FALSE;
  172. }
  173. HRESULT CDocHostUIHandler::FilterDataObject(IDataObject *pDO, IDataObject **ppDORet)
  174. {
  175. TraceMsg(DM_DOCHOSTUIHANDLER, "CDOH::FilterDataObject called");
  176. return S_FALSE;
  177. }