CustSite.cpp
上传用户:szled88
上传日期:2015-04-09
资源大小:43957k
文件大小:5k
源码类别:

对话框与窗口

开发平台:

Visual C++

  1. //=--------------------------------------------------------------------------=
  2. //  (C) Copyright 1996-1999 Microsoft Corporation. All Rights Reserved.
  3. //=--------------------------------------------------------------------------=
  4. // 
  5. // NOTE: 
  6. // Some of the code in this file is MFC implementation specific.
  7. // Changes in future versions of MFC implementation may require
  8. // the code to be changed. Please check the readme of this
  9. // sample for more information 
  10. // 
  11. #include "stdafx.h"
  12. #include "StylerView.h"
  13. #include "Styler.h"
  14. //DEFINE_GUID(CGID_DocHostCommandHandler,0xf38bc242,0xb950,0x11d1,0x89,0x18,0x00,0xc0,0x4f,0xc2,0xc8,0x36);
  15. //static CLSID const CGID_DocHostCommandHandler
  16. // = { 0xf38bc242, 0xb950, 0x11d1, { 0x89,0x18,0x00,0xc0,0x4f,0xc2,0xc8,0x36 } };
  17. BEGIN_INTERFACE_MAP(CStylerView, CCmdTarget)
  18. INTERFACE_PART(CStylerView, IID_IDocHostUIHandler, DocHostUIHandler)
  19. INTERFACE_PART(CStylerView, IID_IOleClientSite, OleClientSite)
  20. INTERFACE_PART(CStylerView, IID_IDispatch, Dispatch)
  21. END_INTERFACE_MAP()
  22. #define DOCHOSTUIFLAG_ENABLE_FORMS_AUTOCOMPLETE 16384
  23. #define IMPLEMENT_INTERFACE_PART(theClass, localClass)
  24. STDMETHODIMP_(ULONG) theClass::X##localClass::AddRef()
  25. {
  26. METHOD_PROLOGUE(theClass, localClass)
  27. return pThis->ExternalAddRef();
  28. }
  29. STDMETHODIMP_(ULONG) theClass::X##localClass::Release()
  30. {
  31.     METHOD_PROLOGUE(theClass, localClass)
  32. return pThis->ExternalRelease();
  33. }
  34. STDMETHODIMP theClass::X##localClass::QueryInterface(REFIID riid, void **ppvObj)
  35. {
  36. METHOD_PROLOGUE(theClass, localClass)
  37.     HRESULT hr = (HRESULT)pThis->ExternalQueryInterface(&riid, ppvObj);
  38. return hr;
  39. }
  40. IMPLEMENT_INTERFACE_PART(CStylerView, DocHostUIHandler)
  41. IMPLEMENT_INTERFACE_PART(CStylerView, OleClientSite)
  42. IMPLEMENT_INTERFACE_PART(CStylerView, Dispatch)
  43. STDMETHODIMP  CStylerView::XDocHostUIHandler::GetHostInfo( DOCHOSTUIINFO* pInfo )
  44. {
  45. pInfo->dwFlags = DOCHOSTUIFLAG_ENABLE_FORMS_AUTOCOMPLETE |DOCHOSTUIFLAG_FLAT_SCROLLBAR|0x40000;
  46.     pInfo->dwDoubleClick = DOCHOSTUIDBLCLK_DEFAULT;
  47.     return S_OK;
  48. }
  49. STDMETHODIMP  CStylerView::XDocHostUIHandler::ShowUI(
  50. DWORD /*dwID*/, 
  51. IOleInPlaceActiveObject * /*pActiveObject*/,
  52. IOleCommandTarget * /*pCommandTarget*/,
  53. IOleInPlaceFrame * /*pFrame*/,
  54. IOleInPlaceUIWindow * /*pDoc*/)
  55. {
  56.     return S_OK;
  57. }
  58. STDMETHODIMP  CStylerView::XDocHostUIHandler::HideUI(void)
  59. {
  60.     return S_OK;
  61. }
  62. STDMETHODIMP  CStylerView::XDocHostUIHandler::UpdateUI(void)
  63. {
  64. return S_OK;
  65. }
  66. STDMETHODIMP  CStylerView::XDocHostUIHandler::EnableModeless(BOOL /*fEnable*/)
  67. {
  68.     return E_NOTIMPL;
  69. }
  70. STDMETHODIMP  CStylerView::XDocHostUIHandler::OnDocWindowActivate(BOOL /*fActivate*/)
  71. {
  72.     return E_NOTIMPL;
  73. }
  74. STDMETHODIMP  CStylerView::XDocHostUIHandler::OnFrameWindowActivate(BOOL /*fActivate*/)
  75. {
  76.     return E_NOTIMPL;
  77. }
  78. STDMETHODIMP CStylerView::XDocHostUIHandler::ResizeBorder(
  79. LPCRECT /*prcBorder*/, 
  80. IOleInPlaceUIWindow* /*pUIWindow*/,
  81. BOOL /*fRameWindow*/)
  82. {
  83.     return E_NOTIMPL;
  84. }
  85. STDMETHODIMP  CStylerView::XDocHostUIHandler::ShowContextMenu(
  86. DWORD /*dwID*/, 
  87. POINT* /*pptPosition*/,
  88. IUnknown* /*pCommandTarget*/,
  89. IDispatch* /*pDispatchObjectHit*/)
  90. {
  91.     return E_NOTIMPL; // We've shown our own context menu. MSHTML.DLL will no longer try to show its own.
  92. }
  93. STDMETHODIMP  CStylerView::XDocHostUIHandler::TranslateAccelerator(LPMSG /*lpMsg*/,
  94.             /* [in] */ const GUID __RPC_FAR* /*pguidCmdGroup*/,
  95.             /* [in] */ DWORD /*nCmdID*/)
  96. {
  97.     return S_FALSE;
  98. }
  99. STDMETHODIMP  CStylerView::XDocHostUIHandler::GetOptionKeyPath(BSTR* /*pbstrKey*/, DWORD)
  100. {
  101. return E_NOTIMPL;
  102. }
  103. STDMETHODIMP CStylerView::XDocHostUIHandler::GetDropTarget( 
  104.             /* [in] */ IDropTarget __RPC_FAR* /*pDropTarget*/,
  105.             /* [out] */ IDropTarget __RPC_FAR *__RPC_FAR* /*ppDropTarget*/)
  106. {
  107. return E_NOTIMPL;
  108. }
  109. STDMETHODIMP CStylerView::XDocHostUIHandler::GetExternal( 
  110.             /* [out] */ IDispatch __RPC_FAR *__RPC_FAR* /*ppDispatch*/)
  111. {
  112. return E_NOTIMPL;
  113. }
  114.         
  115. STDMETHODIMP CStylerView::XDocHostUIHandler::TranslateUrl( 
  116.             /* [in] */ DWORD /*dwTranslate*/,
  117.             /* [in] */ OLECHAR __RPC_FAR* /*pchURLIn*/,
  118.             /* [out] */ OLECHAR __RPC_FAR *__RPC_FAR* /*ppchURLOut*/)
  119. {
  120.     return E_NOTIMPL;
  121. }
  122.         
  123. STDMETHODIMP CStylerView::XDocHostUIHandler::FilterDataObject( 
  124.             /* [in] */ IDataObject __RPC_FAR* /*pDO*/,
  125.             /* [out] */ IDataObject __RPC_FAR *__RPC_FAR* /*ppDORet*/)
  126. {
  127.     return E_NOTIMPL;
  128. }
  129. STDMETHODIMP CStylerView::XDispatch::GetTypeInfoCount(unsigned int*)
  130. {
  131. return E_NOTIMPL;
  132. }
  133. STDMETHODIMP CStylerView::XDispatch::GetTypeInfo(
  134. unsigned int, LCID, ITypeInfo**)
  135. {
  136. return E_NOTIMPL;
  137. }
  138. STDMETHODIMP CStylerView::XDispatch::GetIDsOfNames(
  139. REFIID, LPOLESTR*, unsigned int, LCID, DISPID*)
  140. {
  141. return E_NOTIMPL;
  142. }
  143. STDMETHODIMP CStylerView::XDispatch::Invoke(
  144. DISPID dispid, REFIID, LCID, unsigned short /*wFlags*/,
  145. DISPPARAMS* /*pDispParams*/, VARIANT* pvarResult,
  146. EXCEPINFO*, unsigned int*)
  147. {
  148.     switch (dispid)
  149.     {
  150. case DISPID_AMBIENT_DLCONTROL:
  151. pvarResult->lVal =  DLCTL_VIDEOS | DLCTL_BGSOUNDS;
  152. if (m_bShowImages) pvarResult->lVal |= DLCTL_DLIMAGES;
  153. pvarResult->vt = VT_I4;
  154. break;
  155. default:
  156. return DISP_E_MEMBERNOTFOUND;
  157.     }
  158.     return S_OK;
  159. }