dhuihand.cpp
Upload User: xhy777
Upload Date: 2007-02-14
Package Size: 24088k
Code Size: 7k
Category:

Windows Kernel

Development Platform:

Visual C++

  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.     
  31.     pInfo->dwDoubleClick = DOCHOSTUIDBLCLK_DEFAULT;     // default
  32.     return S_OK;
  33. }
  34. HRESULT CDocHostUIHandler::ShowUI( 
  35.     DWORD dwID, IOleInPlaceActiveObject *pActiveObject,
  36.     IOleCommandTarget *pCommandTarget, IOleInPlaceFrame *pFrame,
  37.     IOleInPlaceUIWindow *pDoc)
  38. {
  39.     TraceMsg(DM_DOCHOSTUIHANDLER, "CDOH::ShowUI called");
  40.     // Host did not display its own UI. Trident will proceed to display its own. 
  41.     return S_FALSE;
  42. }
  43. HRESULT CDocHostUIHandler::HideUI(void)
  44. {
  45.     TraceMsg(DM_DOCHOSTUIHANDLER, "CDOH::HideUI called");
  46.     // This one is paired with ShowUI
  47.     return S_FALSE;
  48. }
  49. HRESULT CDocHostUIHandler::UpdateUI(void)
  50. {
  51.     TraceMsg(DM_DOCHOSTUIHANDLER, "CDOH::UpdateUI called");
  52.     // LATER: Isn't this equivalent to OLECMDID_UPDATECOMMANDS?
  53.     return S_FALSE;
  54. }
  55. HRESULT CDocHostUIHandler::EnableModeless(BOOL fEnable)
  56. {
  57.     TraceMsg(DM_DOCHOSTUIHANDLER, "CDOH::EnableModeless called");
  58.     // Called from the Trident when the equivalent member of its
  59.     // IOleInPlaceActiveObject is called by the frame. We don't care
  60.     // those cases.
  61.     return S_OK;
  62. }
  63. HRESULT CDocHostUIHandler::OnDocWindowActivate(BOOL fActivate)
  64. {
  65.     // Called from the Trident when the equivalent member of its
  66.     // IOleInPlaceActiveObject is called by the frame. We don't care
  67.     // those cases.
  68.     return S_OK;
  69. }
  70. HRESULT CDocHostUIHandler::OnFrameWindowActivate(BOOL fActivate)
  71. {
  72.     // Called from the Trident when the equivalent member of its
  73.     // IOleInPlaceActiveObject is called by the frame. We don't care
  74.     // those cases.
  75.     return S_OK;
  76. }
  77. HRESULT CDocHostUIHandler::ResizeBorder( 
  78. LPCRECT prcBorder, IOleInPlaceUIWindow *pUIWindow, BOOL fRameWindow)
  79. {
  80.     // Called from the Trident when the equivalent member of its
  81.     // IOleInPlaceActiveObject is called by the frame. We don't care
  82.     // those cases.
  83.     return S_OK;
  84. }
  85. HRESULT CDocHostUIHandler::TranslateAccelerator( 
  86. LPMSG lpMsg, const GUID *pguidCmdGroup, DWORD nCmdID)
  87. {
  88.     // Called from the Trident when the equivalent member of its
  89.     // IOleInPlaceActiveObject is called by the frame. We don't care
  90.     // those cases.
  91.     return S_FALSE; // The message was not translated
  92. }
  93. HRESULT CDocHostUIHandler::GetOptionKeyPath(BSTR *pbstrKey, DWORD dw)
  94. {
  95.     // Trident will default to its own user options.
  96.     *pbstrKey = NULL;
  97.     return S_FALSE;
  98. }
  99. HRESULT CDocHostUIHandler::GetDropTarget(IDropTarget *pDropTarget, IDropTarget **ppDropTarget)
  100. {
  101.     TraceMsg(DM_DOCHOSTUIHANDLER, "CDOH::GetDropTarget called");
  102.     return E_NOTIMPL;
  103. }
  104. HRESULT CDocHostUIHandler::GetAltExternal(IDispatch **ppDisp)
  105. {
  106.     HRESULT hr = E_FAIL;
  107.     
  108.     IServiceProvider  *psp;
  109.     IDocHostUIHandler *pDocHostUIHandler;
  110.     IOleObject        *pOleObject;
  111.     IOleClientSite    *pOleClientSite;
  112.     *ppDisp = NULL;
  113.     //  * QI ourselves for a service provider
  114.     //  * QS for the top level browser's service provider
  115.     //  * Ask for an IOleObject
  116.     //  * Ask the IOleObject for an IOleClientSite
  117.     //  * QI the IOleClientSite for an IDocHostUIHandler
  118.     //  * Call GetExternal on the IDocHostUIHandler to get the IDispatch
  119.     if (SUCCEEDED(IUnknown_QueryService(this, 
  120.                                         SID_STopLevelBrowser,
  121.                                         IID_IServiceProvider, 
  122.                                         (void **)&psp)))
  123.     {
  124.         if (SUCCEEDED(psp->QueryService(SID_SWebBrowserApp, IID_IOleObject,
  125.                                         (void **)&pOleObject)))
  126.         {
  127.             if (SUCCEEDED(pOleObject->GetClientSite(&pOleClientSite)))
  128.             {
  129.                 if (SUCCEEDED(pOleClientSite->QueryInterface(IID_IDocHostUIHandler,
  130.                                                              (void **)&pDocHostUIHandler)))
  131.                 {
  132.                     hr = pDocHostUIHandler->GetExternal(ppDisp);
  133.                     pDocHostUIHandler->Release();
  134.                 }
  135.                 pOleClientSite->Release();
  136.             }
  137.             pOleObject->Release();
  138.         }
  139.         psp->Release();
  140.     }
  141.     return hr;
  142. }
  143. HRESULT CDocHostUIHandler::GetExternal(IDispatch **ppDisp)
  144. {
  145.     TraceMsg(DM_DOCHOSTUIHANDLER, "CDOH::GetExternal called");
  146.     HRESULT hr;
  147.     if (ppDisp)
  148.     {
  149.         IDispatch *psuihDisp;
  150.         IDispatch *pAltExternalDisp;
  151.         *ppDisp = NULL;
  152.         GetAltExternal(&pAltExternalDisp);
  153.         hr = CShellUIHelper_CreateInstance2((IUnknown **)&psuihDisp, IID_IDispatch,
  154.                                            (IUnknown *)this, pAltExternalDisp);
  155.         if (SUCCEEDED(hr))
  156.         {
  157.             *ppDisp = psuihDisp;
  158.             if (pAltExternalDisp)
  159.             {
  160.                 //  Don't hold a ref - the ShellUIHelper will do it
  161.                 pAltExternalDisp->Release();
  162.             }
  163.         }
  164.         else if (pAltExternalDisp)
  165.         {
  166.             //  Couldn't create a ShellUIHelper but we got our host's
  167.             //  external.
  168.             *ppDisp = pAltExternalDisp;
  169.             hr = S_OK;
  170.         }
  171.     }
  172.     else
  173.     {
  174.         hr = E_INVALIDARG;
  175.     }
  176.     ASSERT((SUCCEEDED(hr) && (*ppDisp)) || (FAILED(hr)));
  177.     return hr;
  178. }
  179. HRESULT CDocHostUIHandler::TranslateUrl(DWORD dwTranslate, OLECHAR *pchURLIn, OLECHAR **ppchURLOut)
  180. {
  181.     TraceMsg(DM_DOCHOSTUIHANDLER, "CDOH::TranslateUrl called");
  182.     return S_FALSE;
  183. }
  184. HRESULT CDocHostUIHandler::FilterDataObject(IDataObject *pDO, IDataObject **ppDORet)
  185. {
  186.     TraceMsg(DM_DOCHOSTUIHANDLER, "CDOH::FilterDataObject called");
  187.     return S_FALSE;
  188. }