Chinaunix首页 | 论坛 | 博客
  • 博客访问: 640447
  • 博文数量: 133
  • 博客积分: 1566
  • 博客等级: 上尉
  • 技术积分: 1230
  • 用 户 组: 普通用户
  • 注册时间: 2010-12-01 09:31
文章分类

全部博文(133)

文章存档

2019年(1)

2018年(1)

2017年(8)

2016年(9)

2015年(17)

2014年(4)

2013年(31)

2012年(25)

2011年(36)

2010年(1)

我的朋友

分类: C/C++

2013-04-18 11:35:29


HtmlCtrl.h


点击(此处)折叠或打开

  1. #pragma once

  2. #include <afxhtml.h>
  3. #include <afxocc.h>
  4. #include <MsHtmdid.h>


  5. class CHtmlCtrl;
  6. class CHtmlNewWndWatch;

  7. #include "HtmlFilter.h"


  8. class CHtmlCtrl:
  9.     public CHtmlView
  10. {
  11.     DECLARE_DYNAMIC(CHtmlCtrl)

  12.     typedef void (AFX_MSG_CALL CCmdTarget::*ADD_MENU_PROC)(CMenu* pPopupMenu, UINT nIndex);

  13.     enum MENU_TYPE            // 上下文菜单
  14.     {
  15.         NoMenu,                // 无菜单
  16.         DefaultMenu,        // 默认菜单
  17.         TextSelectionOnly,    // 仅文本选择菜单
  18.         DefAddMenu,            //
  19.         CustomMenu            // 自定义菜单
  20.     };


  21. public:
  22.     CHtmlCtrl();
  23.     ~CHtmlCtrl();


  24. //    新加功能
  25.     BOOL    CreateFromStatic(CWnd *pStaticWnd);
  26.     BOOL    EnableNewWindow(BOOL bNewWindow);
  27.     BOOL    GetNewWindowEnable();
  28.     BOOL    SetContextMenuMode(MENU_TYPE MenuMode);
  29.     BOOL    SetAddMenu(int nMenuID, CWnd *pMenuNtyWnd = NULL);
  30.     BOOL    SetAddMenuInitProcess(CCmdTarget *pTarget, ADD_MENU_PROC AddMenuProc);

  31.     BOOL    InstallMinme();

  32.     BOOL    BrowserExeWB(OLECMDID cmdID, OLECMDEXECOPT cmdexecopt, VARIANT * pvaIn, VARIANT * pvaOut);
  33.     BOOL    CmdTargetExec(DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut);

  34. //    网页操作

  35.     BOOL    Web_Find();
  36.     BOOL    Web_GetFontSize(LONG *pSize);
  37.     BOOL    Web_SetFontSize(LONG lSize);



  38. //    成员变量
  39.     BOOL            m_bNewWindow;
  40.     HWND            m_hStaticWnd;
  41.     CHtmlView *        m_pHtmlView;
  42.     CString            m_DefaultMsgBoxTitle;
  43.     MENU_TYPE        m_MenuType;
  44.     UINT            m_uAddMenuID;
  45.     CMenu            m_DefaultMenu;
  46.     CWnd *            m_pMenuNtyWnd;
  47.     ADD_MENU_PROC    m_AddMenuProc;
  48.     CCmdTarget *    m_pAddMenuTarget;

  49.     CHtmlFilter                    m_HtmFilter;
  50.     CComPtr<IInternetSession>    m_pSession;


  51. //    原虚函数
  52.     virtual BOOL CreateControlSite(COleControlContainer* pContainer,COleControlSite** ppSite, UINT nID, REFCLSID clsid);
  53.     virtual void OnNewWindow2(LPDISPATCH* ppDisp, BOOL* Cancel);
  54.     virtual void PostNcDestroy() { }
  55.     virtual void OnBeforeNavigate2( LPCTSTR lpszURL,
  56.         DWORD nFlags,
  57.         LPCTSTR lpszTargetFrameName,
  58.         CByteArray& baPostedData,
  59.         LPCTSTR lpszHeaders,
  60.         BOOL* pbCancel );
  61.     virtual HRESULT OnShowContextMenu(DWORD dwID, LPPOINT ppt, LPUNKNOWN pcmdtReserved, LPDISPATCH pdispReserved);
  62.     virtual    HRESULT OnGetOverrideKeyPath(LPOLESTR * pchKey, DWORD dw);
  63.     virtual    BOOL    OnAmbientProperty(COleControlSite* pSite, DISPID dispid, VARIANT* pvar);

  64. //    新加虚函数
  65.     virtual void OnAppCmd(LPCTSTR lpszWhere);
  66.     virtual void OnWatchNewWind(LPCTSTR lpszURL);
  67.     virtual HRESULT OnShowMessage(HWND hwnd,LPOLESTR lpstrText,LPOLESTR lpstrCaption,DWORD dwType,LPOLESTR lpstrHelpFile,DWORD dwHelpContext,LRESULT * plResult);
  68.     virtual HRESULT OnShowCustomContextMenu(LPPOINT ppt, LPUNKNOWN pcmdtReserved,LPDISPATCH pdispReserved);
  69.     virtual HRESULT    ShowAddMenu(DWORD dwID, POINT *ppt, IUnknown *pcmdTarget, LPDISPATCH pdispReserved);
  70.     virtual    void OnInitAddMenu(CMenu* pPopupMenu, UINT nIndex);
  71. //    私有方法
  72.     BOOL    GetDefaultMenu(DWORD dwID, IUnknown *pcmdTarget, CMenu **ppMenu);


  73. private:



  74. public:
  75.     DECLARE_MESSAGE_MAP();

  76.     afx_msg void OnDestroy();
  77.     afx_msg int OnMouseActivate(CWnd* pDesktopWnd, UINT nHitTest, UINT msg);
  78.     afx_msg void OnContextMenu(CWnd* /*pWnd*/, CPoint /*point*/);
  79.     afx_msg void OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu);
  80. };


  81. class CHtmMneuWnd:
  82.     public CWnd
  83. {
  84.     DECLARE_DYNAMIC(CHtmMneuWnd)
  85. public:

  86.     CHtmMneuWnd()
  87.     {
  88.     }

  89.     CHtmMneuWnd(CHtmlCtrl *pHtmCtrl)
  90.     {
  91.         m_pHtmCtrl = pHtmCtrl;
  92.     }
  93.     ~CHtmMneuWnd()
  94.     {
  95.     }

  96.     BOOL    SetHtmCtrl(CHtmlCtrl *pHtmCtrl)
  97.     {
  98.         m_pHtmCtrl = pHtmCtrl;
  99.         return TRUE;
  100.     }

  101.     BOOL    SetActionMenu(CMenu *pActionMenu, CMenu *pAddMenu, CString &AddMenuString)
  102.     {
  103.         m_pActionMenu = pActionMenu;
  104.         m_pAddMenu = pAddMenu;
  105.         m_AddMenuString = AddMenuString;

  106.         return TRUE;
  107.     }


  108.     DECLARE_MESSAGE_MAP();

  109.     afx_msg void OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu)
  110.     {
  111. //        int                i;

  112.         CWnd::OnInitMenuPopup(pPopupMenu, nIndex, bSysMenu);
  113.         if(pPopupMenu->GetSafeHmenu() == m_pAddMenu->GetSafeHmenu())
  114.         {
  115.             m_pHtmCtrl->OnInitAddMenu(pPopupMenu, nIndex);
  116.         }

  117.         if(pPopupMenu->GetSafeHmenu() == m_pActionMenu->GetSafeHmenu())
  118.         {
  119.             pPopupMenu->InsertMenu(0, MF_POPUP | MF_BYPOSITION,
  120.                 (UINT)(__int64)m_pAddMenu->GetSafeHmenu(), m_AddMenuString);
  121.         }

  122.         return;
  123.     }

  124.     CDWordArray            m_IdList;
  125.     CHtmlCtrl *            m_pHtmCtrl;
  126.     CMenu *                m_pActionMenu;
  127.     CMenu *                m_pAddMenu;
  128.     CString                m_AddMenuString;
  129. };


  130. class CHtmlNewWndWatch:
  131.     public CHtmlView
  132. {
  133.     DECLARE_DYNAMIC(CHtmlNewWndWatch)

  134. public:
  135.     CHtmlNewWndWatch();
  136.     CHtmlNewWndWatch(CHtmlCtrl *pParent);

  137.     static CHtmlNewWndWatch *    CreateNewWatch(CHtmlCtrl *pParent);
  138.     static VOID WINAPIV     DeleteWatch();

  139.     ~CHtmlNewWndWatch();

  140.     virtual void OnBeforeNavigate2(LPCTSTR lpszURL,
  141.         DWORD nFlags,
  142.         LPCTSTR lpszTargetFrameName,
  143.         CByteArray& baPostedData,
  144.         LPCTSTR lpszHeaders,
  145.         BOOL* pbCancel);


  146.     CHtmlCtrl        *m_pHtmlCtrl;
  147.     static    CHtmlNewWndWatch *s_pOnceInstance;
  148. };





  149. class CHtmControlSite : public COleControlSite
  150. {
  151. public:
  152.     CHtmControlSite(COleControlContainer * pOCC, CHtmlCtrl* pView);
  153.     virtual ~CHtmControlSite();

  154. private:
  155.     CHtmlCtrl *        m_pView;

  156.     // IDocHostShowUI
  157. protected:
  158.     BEGIN_INTERFACE_PART(DocHostShowUI, IDocHostShowUI)
  159.         INIT_INTERFACE_PART(CHtmControlSite, DocHostShowUI)
  160.         STDMETHOD(ShowHelp)(
  161.         /* [in ] */    HWND hwnd,
  162.         /* [in ] */    LPOLESTR pszHelpFile,
  163.         /* [in ] */    UINT uCommand,
  164.         /* [in ] */    DWORD dwData,
  165.         /* [in ] */    POINT ptMouse,
  166.         /* [out] */    IDispatch __RPC_FAR *pDispatchObjectHit);
  167.         STDMETHOD(ShowMessage)(
  168.         /* [in ] */    HWND hwnd,
  169.         /* [in ] */    LPOLESTR lpstrText,
  170.         /* [in ] */    LPOLESTR lpstrCaption,
  171.         /* [in ] */    DWORD dwType,
  172.         /* [in ] */    LPOLESTR lpstrHelpFile,
  173.         /* [in ] */    DWORD dwHelpContext,
  174.         /* [out] */    LRESULT __RPC_FAR *plResult);
  175.     END_INTERFACE_PART(DocHostShowUI)

  176.     // IDocHostUIHandler
  177. protected:
  178.     BEGIN_INTERFACE_PART(DocHostUIHandler, IDocHostUIHandler)
  179.         STDMETHOD(ShowContextMenu)(/* [in] */ DWORD dwID,
  180.         /* [in] */ POINT __RPC_FAR *ppt,
  181.         /* [in] */ IUnknown __RPC_FAR *pcmdtReserved,
  182.         /* [in] */ IDispatch __RPC_FAR *pdispReserved);
  183.         STDMETHOD(GetHostInfo)(
  184.         /* [out][in] */ DOCHOSTUIINFO __RPC_FAR *pInfo);
  185.         STDMETHOD(ShowUI)(
  186.         /* [in] */ DWORD dwID,
  187.         /* [in] */ IOleInPlaceActiveObject __RPC_FAR *pActiveObject,
  188.         /* [in] */ IOleCommandTarget __RPC_FAR *pCommandTarget,
  189.         /* [in] */ IOleInPlaceFrame __RPC_FAR *pFrame,
  190.         /* [in] */ IOleInPlaceUIWindow __RPC_FAR *pDoc);
  191.         STDMETHOD(HideUI)(void);
  192.         STDMETHOD(UpdateUI)(void);
  193.         STDMETHOD(EnableModeless)(/* [in] */ BOOL fEnable);
  194.         STDMETHOD(OnDocWindowActivate)(/* [in] */ BOOL fEnable);
  195.         STDMETHOD(OnFrameWindowActivate)(/* [in] */ BOOL fEnable);
  196.         STDMETHOD(ResizeBorder)(
  197.             /* [in] */ LPCRECT prcBorder,
  198.             /* [in] */ IOleInPlaceUIWindow __RPC_FAR *pUIWindow,
  199.             /* [in] */ BOOL fRameWindow);
  200.             STDMETHOD(TranslateAccelerator)(
  201.             /* [in] */ LPMSG lpMsg,
  202.             /* [in] */ const GUID __RPC_FAR *pguidCmdGroup,
  203.             /* [in] */ DWORD nCmdID);
  204.             STDMETHOD(GetOptionKeyPath)(
  205.             /* [out] */ LPOLESTR __RPC_FAR *pchKey,
  206.             /* [in] */ DWORD dw);
  207.             STDMETHOD(GetDropTarget)(
  208.             /* [in] */ IDropTarget __RPC_FAR *pDropTarget,
  209.             /* [out] */ IDropTarget __RPC_FAR *__RPC_FAR *ppDropTarget);
  210.             STDMETHOD(GetExternal)(
  211.             /* [out] */ IDispatch __RPC_FAR *__RPC_FAR *ppDispatch);
  212.             STDMETHOD(TranslateUrl)(
  213.             /* [in] */ DWORD dwTranslate,
  214.             /* [in] */ OLECHAR __RPC_FAR *pchURLIn,
  215.             /* [out] */ OLECHAR __RPC_FAR *__RPC_FAR *ppchURLOut);
  216.             STDMETHOD(FilterDataObject)(
  217.             /* [in] */ IDataObject __RPC_FAR *pDO,
  218.             /* [out] */ IDataObject __RPC_FAR *__RPC_FAR *ppDORet);
  219.     END_INTERFACE_PART(DocHostUIHandler)

  220. #if (_WIN32_IE >= 0x0501) // IE 5.5 and higher
  221.     // IDocHostUIHandler2
  222. protected:
  223.     BEGIN_INTERFACE_PART(DocHostUIHandler2, IDocHostUIHandler2)
  224.         STDMETHOD(GetOverrideKeyPath)(
  225.         /* [out] */ LPOLESTR __RPC_FAR *pchKey,
  226.         /* [in] */ DWORD dw);
  227.         STDMETHOD(ShowContextMenu)(/* [in] */ DWORD dwID,
  228.         /* [in] */ POINT __RPC_FAR *ppt,
  229.         /* [in] */ IUnknown __RPC_FAR *pcmdtReserved,
  230.         /* [in] */ IDispatch __RPC_FAR *pdispReserved);
  231.         STDMETHOD(GetHostInfo)(
  232.         /* [out][in] */ DOCHOSTUIINFO __RPC_FAR *pInfo);
  233.         STDMETHOD(ShowUI)(
  234.         /* [in] */ DWORD dwID,
  235.         /* [in] */ IOleInPlaceActiveObject __RPC_FAR *pActiveObject,
  236.         /* [in] */ IOleCommandTarget __RPC_FAR *pCommandTarget,
  237.         /* [in] */ IOleInPlaceFrame __RPC_FAR *pFrame,
  238.         /* [in] */ IOleInPlaceUIWindow __RPC_FAR *pDoc);
  239.         STDMETHOD(HideUI)(void);
  240.         STDMETHOD(UpdateUI)(void);
  241.         STDMETHOD(EnableModeless)(/* [in] */ BOOL fEnable);
  242.         STDMETHOD(OnDocWindowActivate)(/* [in] */ BOOL fEnable);
  243.         STDMETHOD(OnFrameWindowActivate)(/* [in] */ BOOL fEnable);
  244.         STDMETHOD(ResizeBorder)(
  245.             /* [in] */ LPCRECT prcBorder,
  246.             /* [in] */ IOleInPlaceUIWindow __RPC_FAR *pUIWindow,
  247.             /* [in] */ BOOL fRameWindow);
  248.             STDMETHOD(TranslateAccelerator)(
  249.             /* [in] */ LPMSG lpMsg,
  250.             /* [in] */ const GUID __RPC_FAR *pguidCmdGroup,
  251.             /* [in] */ DWORD nCmdID);
  252.             STDMETHOD(GetOptionKeyPath)(
  253.             /* [out] */ LPOLESTR __RPC_FAR *pchKey,
  254.             /* [in] */ DWORD dw);
  255.             STDMETHOD(GetDropTarget)(
  256.             /* [in] */ IDropTarget __RPC_FAR *pDropTarget,
  257.             /* [out] */ IDropTarget __RPC_FAR *__RPC_FAR *ppDropTarget);
  258.             STDMETHOD(GetExternal)(
  259.             /* [out] */ IDispatch __RPC_FAR *__RPC_FAR *ppDispatch);
  260.             STDMETHOD(TranslateUrl)(
  261.             /* [in] */ DWORD dwTranslate,
  262.             /* [in] */ OLECHAR __RPC_FAR *pchURLIn,
  263.             /* [out] */ OLECHAR __RPC_FAR *__RPC_FAR *ppchURLOut);
  264.             STDMETHOD(FilterDataObject)(
  265.             /* [in] */ IDataObject __RPC_FAR *pDO,
  266.             /* [out] */ IDataObject __RPC_FAR *__RPC_FAR *ppDORet);
  267.     END_INTERFACE_PART(DocHostUIHandler2)
  268. #endif

  269.     // Implement IInternetSecurityManager
  270.     BEGIN_INTERFACE_PART(InternetSecurityManager, IInternetSecurityManager)
  271.         STDMETHOD(SetSecuritySite)(IInternetSecurityMgrSite*);
  272.         STDMETHOD(GetSecuritySite)(IInternetSecurityMgrSite**);
  273.         STDMETHOD(MapUrlToZone)(LPCWSTR,DWORD*,DWORD);
  274.         STDMETHOD(GetSecurityId)(LPCWSTR,BYTE*,DWORD*,DWORD);
  275.         STDMETHOD(ProcessUrlAction)(
  276.             /* [in] */ LPCWSTR pwszUrl,
  277.             /* [in] */ DWORD dwAction,
  278.             /* [size_is][out] */ BYTE __RPC_FAR *pPolicy,
  279.             /* [in] */ DWORD cbPolicy,
  280.             /* [in] */ BYTE __RPC_FAR *pContext,
  281.             /* [in] */ DWORD cbContext,
  282.             /* [in] */ DWORD dwFlags,
  283.             /* [in] */ DWORD dwReserved = 0);
  284.             STDMETHOD(QueryCustomPolicy)(LPCWSTR,REFGUID,BYTE**,DWORD*,BYTE*,DWORD,DWORD);
  285.         STDMETHOD(SetZoneMapping)(DWORD,LPCWSTR,DWORD);
  286.         STDMETHOD(GetZoneMappings)(DWORD,IEnumString**,DWORD);
  287.     END_INTERFACE_PART(InternetSecurityManager)


  288.     ///////////////////////////////////////
  289.     //// Implement IServiceProvider
  290.     BEGIN_INTERFACE_PART(ServiceProvider, IServiceProvider)
  291.         STDMETHOD(QueryService)(REFGUID,REFIID,void**);
  292.     END_INTERFACE_PART(ServiceProvider)


  293.     BEGIN_INTERFACE_PART(MyAmbientProps, IDispatch)
  294.  //        INIT_INTERFACE_PART(CHtmControlSite, MyAmbientProps)
  295.         STDMETHOD(GetTypeInfoCount)(unsigned int*);
  296.         STDMETHOD(GetTypeInfo)(unsigned int, LCID, ITypeInfo**);
  297.         STDMETHOD(GetIDsOfNames)(REFIID, LPOLESTR*, unsigned int, LCID, DISPID*);
  298.         STDMETHOD(Invoke)(DISPID dispidMember,REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS * pdispparams,
  299.             VARIANT * pvarResult, EXCEPINFO * pexcepinfo, UINT * puArgErr);
  300.     END_INTERFACE_PART(MyAmbientProps)


  301.     DECLARE_INTERFACE_MAP()
  302. };


HtmlCtrl.cpp

点击(此处)折叠或打开

  1. ////////////////////////////////////////////////////////////////
  2. // If this code works, it was written by Paul DiLascia.
  3. // If not, I don't know who wrote it.
  4. // Compiles with Visual C++ 6.0, runs on Windows 98 and probably NT too.
  5. //
  6. #include "StdAfx.h"
  7. #include "HtmlCtrl.h"

  8. #include <IDispIds.h>

  9. //#define HCT_TRACE    ATLTRACE
  10. #define HCT_TRACE    __noop


  11. #define ID_MYUSED_BASE    30000

  12. #define WM_CREATE_HTM    WM_USER + 1231
  13. #define MENU_ID_GOTO    ID_MYUSED_BASE + 0
  14. #define MENU_ID_HOST    ID_MYUSED_BASE + 1


  15. #ifdef _DEBUG
  16. #define new DEBUG_NEW
  17. #undef THIS_FILE
  18. static char THIS_FILE[] = __FILE__;
  19. #endif



  20. /////////////////////////////////////////////////////////////////////////////
  21. //                CHtmlCtrl
  22. /////////////////////////////////////////////////////////////////////////////
  23. CHtmlCtrl::CHtmlCtrl()
  24. {
  25.     m_bNewWindow = FALSE;
  26.     m_MenuType = DefaultMenu;
  27.     m_pAddMenuTarget = NULL;
  28.     m_AddMenuProc = NULL;
  29. }

  30. CHtmlCtrl::~CHtmlCtrl()
  31. {

  32. }


  33. IMPLEMENT_DYNAMIC(CHtmlCtrl, CHtmlView)
  34. BEGIN_MESSAGE_MAP(CHtmlCtrl, CHtmlView)
  35.     ON_WM_DESTROY()
  36.     ON_WM_MOUSEACTIVATE()
  37.     ON_WM_CONTEXTMENU()
  38.     ON_WM_INITMENUPOPUP()
  39. END_MESSAGE_MAP()


  40. void CHtmlCtrl::OnDestroy()
  41. {
  42.     //    if (m_pBrowserApp) {
  43.     //        m_pBrowserApp->Release();
  44.     //        m_pBrowserApp = NULL;
  45.     //    }
  46.     CHtmlView::OnDestroy(); // bypass CView doc/frame stuff
  47. }


  48. int CHtmlCtrl::OnMouseActivate(CWnd* pDesktopWnd, UINT nHitTest, UINT msg)
  49. {
  50.     // bypass CView doc/frame stuff
  51.     return CWnd::OnMouseActivate(pDesktopWnd, nHitTest, msg);
  52. }

  53. void CHtmlCtrl::OnContextMenu(CWnd* /*pWnd*/, CPoint /*point*/)
  54. {
  55.     // TODO: Add your message handler code here
  56. }

  57. void CHtmlCtrl::OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu)
  58. {
  59.     CHtmlView::OnInitMenuPopup(pPopupMenu, nIndex, bSysMenu);

  60.     // TODO: Add your message handler code here
  61. }

  62. //    消息映射函数 结束
  63. //////////////////////////////////////////////////////////////////////////////////////////////


  64. //////////////////////////////////////////////////////////////////////////////////////////////
  65. //    新加功能    开始
  66. BOOL CHtmlCtrl::CreateFromStatic(CWnd *pStaticWnd)
  67. {
  68.     CWnd *        pParent;
  69.     int            nID;

  70.     pParent = pStaticWnd->GetParent();
  71.     nID = pStaticWnd->GetDlgCtrlID();

  72.     // Get static control rect, convert to parent's client coords.
  73.     CRect rc;
  74.     pStaticWnd->GetWindowRect(&rc);
  75.     pParent->ScreenToClient(&rc);
  76.     pStaticWnd->ShowWindow(SW_HIDE);
  77.     pStaticWnd->DestroyWindow();

  78.     // create HTML control (CHtmlView)
  79.     return Create(NULL,                         // class name
  80.         NULL,                                         // title
  81.         (WS_CHILD | WS_VISIBLE ),             // style
  82.         rc,                                         // rectangle
  83.         pParent,                                     // parent
  84.         nID,                                         // control ID
  85.         NULL);                                     // frame/doc context not used
  86. }


  87. BOOL    CHtmlCtrl::EnableNewWindow(BOOL bNewWindow)
  88. {
  89.     m_bNewWindow = bNewWindow;
  90.     return TRUE;
  91. }

  92. BOOL    CHtmlCtrl::GetNewWindowEnable()
  93. {
  94.     return m_bNewWindow;
  95. }

  96. BOOL    CHtmlCtrl::SetContextMenuMode(MENU_TYPE MenuMode)
  97. {
  98.     m_MenuType = MenuMode;
  99.     return TRUE;
  100. }


  101. BOOL    CHtmlCtrl::SetAddMenu(int nMenuID, CWnd *pMenuNtyWnd)
  102. {
  103.     m_uAddMenuID = nMenuID;

  104.     if(pMenuNtyWnd == NULL)
  105.         m_pMenuNtyWnd = this->GetParent();
  106.     else
  107.         m_pMenuNtyWnd = pMenuNtyWnd;

  108.     SetContextMenuMode(DefAddMenu);
  109.     return TRUE;
  110. }


  111. BOOL    CHtmlCtrl::SetAddMenuInitProcess(CCmdTarget *pTarget, ADD_MENU_PROC AddMenuProc)
  112. {
  113.     m_AddMenuProc = AddMenuProc;
  114.     m_pAddMenuTarget = pTarget;

  115.     return TRUE;
  116. }


  117. BOOL    CHtmlCtrl::InstallMinme()
  118. {
  119.     HRESULT                        hr;
  120.     CComPtr<IClassFactory>        spFact;
  121.     WCHAR        *pMime;
  122.     int            i;

  123.     hr = ::CoInternetGetSession(0, &m_pSession, 0);
  124.     if(FAILED(hr))
  125.         return FALSE;

  126. //    m_HtmFilter.QueryInterface(IID_ICallFactory, (LPVOID *)&spFact);
  127.     spFact = &m_HtmFilter;

  128.     hr = FindMimeFromData(NULL, L"*.htm", NULL, 0, NULL, 0, &pMime, 0);
  129.     hr = FindMimeFromData(NULL, L"*.js", NULL, 0, NULL, 0, &pMime, 0);

  130.     hr = FindMimeFromData(NULL, L"*.css", NULL, 0, NULL, 0, &pMime, 0);
  131. //    hr = FindMimeFromData(NULL, L"*.jpg", NULL, 0, NULL, 0, &pMime, 0);

  132.     m_HtmFilter.AddRef();
  133. #if 0
  134.     m_HtmFilter.m_nFilterType = Filter_namespcae;
  135.     hr = m_pSession->RegisterNameSpace(spFact, CLSID_HtmlFilter, L"http", 0, NULL, 0);
  136. #else

  137.     WCHAR        *pFilterList[] =
  138.     {
  139.         L"application/x-javascript",
  140.         L"",

  141.         L"text/html",
  142.         L"text/javascrip",
  143.         L"image/gif",
  144.         L"image/x-xbitmap",
  145.         L"image/jpeg",
  146.         L"image/pjpeg",
  147.         L"application/x-shockwave-flash",
  148.         L"application/vnd.ms-powerpoint",
  149.         L"application/vnd.ms-excel",
  150.         L"application/msword",
  151.         L"application/x-silverlight",
  152.         L"*/*",
  153.         NULL
  154.     };

  155.     m_HtmFilter.m_nFilterType = Filter_Mime;
  156.     for(i=0; pFilterList[i]; i++)
  157.     {
  158.         hr = m_pSession->RegisterMimeFilter(spFact, CLSID_HtmlFilter, pFilterList[i]);
  159.     }
  160. #endif

  161.     if(FAILED(hr))
  162.         return FALSE;

  163.     return TRUE;
  164. }
  165. //    新加功能    结束
  166. //////////////////////////////////////////////////////////////////////////////////////////////


  167. BOOL    CHtmlCtrl::BrowserExeWB(OLECMDID cmdID, OLECMDEXECOPT cmdexecopt, VARIANT * pvaIn, VARIANT * pvaOut)
  168. {
  169.     CComQIPtr<IWebBrowser2, &IID_IWebBrowser2>    spWebBrowser2;
  170.     HRESULT            hr;

  171.     spWebBrowser2 = m_pBrowserApp;
  172.     hr = spWebBrowser2->ExecWB(cmdID, cmdexecopt, pvaIn, pvaOut);
  173.     if(FAILED(hr))
  174.     {
  175.         assert(0);
  176.         return FALSE;
  177.     }

  178.     return TRUE;
  179. }

  180. BOOL    CHtmlCtrl::CmdTargetExec(DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
  181. {
  182.     CComPtr<IOleCommandTarget>        pCmd;
  183.     CComPtr<IHTMLDocument2>            pDoc;
  184.     HRESULT            hr;

  185.     pDoc = (IHTMLDocument2 *)GetHtmlDocument();
  186.     pCmd = pDoc;
  187.     if(pCmd == NULL)
  188.     {
  189.         assert(0);
  190.         return FALSE;
  191.     }

  192.     hr = pCmd->Exec(&CGID_MSHTML, nCmdID, nCmdexecopt, pvaIn, pvaOut);
  193.     if(FAILED(hr))
  194.     {
  195.         assert(0);
  196.         return FALSE;
  197.     }

  198.     return TRUE;
  199. }

  200. BOOL    CHtmlCtrl::Web_Find()
  201. {
  202.     _variant_t        vtIn, vtOut;
  203.     BOOL            bRetVal;

  204.     bRetVal = CmdTargetExec(IDM_FIND, OLECMDEXECOPT_DODEFAULT, &vtIn, &vtOut);
  205.     return bRetVal;
  206. }

  207. BOOL    CHtmlCtrl::Web_GetFontSize(LONG *pSize)
  208. {
  209.     _variant_t        vtIn, vtOut;
  210.     BOOL            bRetVal;

  211.     bRetVal = BrowserExeWB(OLECMDID_ZOOM, OLECMDEXECOPT_DONTPROMPTUSER, &vtIn, &vtOut);
  212.     if(bRetVal)
  213.         *pSize = vtOut.lVal;
  214.     else
  215.         *pSize = -1;
  216.     return bRetVal;
  217. }

  218. BOOL    CHtmlCtrl::Web_SetFontSize(LONG lSize)
  219. {
  220.     _variant_t        vtIn, vtOut;
  221.     BOOL            bRetVal;

  222.     vtIn = lSize;
  223.     bRetVal = BrowserExeWB(OLECMDID_ZOOM, OLECMDEXECOPT_DONTPROMPTUSER, &vtIn, &vtOut);
  224.     if(vtOut.lVal != lSize)
  225.         assert(0);

  226.     return bRetVal;
  227. }

  228. //////////////////////////////////////////////////////////////////////////////////////////////
  229. //    原虚函数    开始
  230. BOOL CHtmlCtrl::CreateControlSite(COleControlContainer * pContainer, COleControlSite ** ppSite, UINT /*nID*/, REFCLSID /*clsid*/)
  231. {
  232.     *ppSite = new CHtmControlSite(pContainer, this);// 创建自己的控制站点实例

  233.     return (*ppSite) ? TRUE : FALSE;
  234. }


  235. void CHtmlCtrl::OnNewWindow2(LPDISPATCH* ppDisp, BOOL* Cancel)
  236. {
  237.     CHtmlNewWndWatch *        pWatch;

  238.     if(m_bNewWindow)
  239.         return;

  240.     pWatch = CHtmlNewWndWatch::CreateNewWatch(this);

  241.     pWatch->SetRegisterAsBrowser(FALSE);
  242.     *ppDisp = pWatch->GetApplication();

  243.     return;
  244. }



  245. void CHtmlCtrl::OnBeforeNavigate2( LPCTSTR lpszURL,
  246.                                  DWORD nFlags,
  247.                                  LPCTSTR lpszTargetFrameName,
  248.                                  CByteArray& baPostedData,
  249.                                  LPCTSTR lpszHeaders,
  250.                                  BOOL* pbCancel)
  251. {
  252.     const TCHAR APP_PROTOCOL[] = _T("app:");
  253.     int len = (int)_tcslen(APP_PROTOCOL);
  254.     if (_tcsnicmp(lpszURL, APP_PROTOCOL, len)==0)
  255.     {
  256.         OnAppCmd(lpszURL + len);
  257.         *pbCancel = TRUE;
  258.     }

  259.     return CHtmlView::OnBeforeNavigate2(lpszURL,
  260.         nFlags,
  261.         lpszTargetFrameName,
  262.         baPostedData,
  263.         lpszHeaders,
  264.         pbCancel);
  265. }
  266. //    原虚函数    结束
  267. //////////////////////////////////////////////////////////////////////////////////////////////



  268. //////////////////////////////////////////////////////////////////////////////////////////////
  269. //    新加虚函数    开始
  270. void CHtmlCtrl::OnAppCmd(LPCTSTR lpszWhere)
  271. {
  272.     // default: do nothing
  273. }

  274. void CHtmlCtrl::OnWatchNewWind(LPCTSTR lpszURL)
  275. {
  276.     this->Navigate(lpszURL);
  277. }

  278. HRESULT CHtmlCtrl::OnShowContextMenu(DWORD dwID, LPPOINT ppt,LPUNKNOWN pcmdtReserved, LPDISPATCH pdispReserved)
  279. {
  280.     HRESULT result = S_FALSE;

  281.     switch(m_MenuType)
  282.     {
  283.     case NoMenu:                // 无菜单
  284.         result=S_OK;
  285.         break;
  286.     case DefaultMenu:            // 默认菜单
  287.         break;
  288.     case TextSelectionOnly:        // 仅文本选择菜单
  289.         if(!(dwID == CONTEXT_MENU_TEXTSELECT || dwID == CONTEXT_MENU_CONTROL))
  290.             result = S_OK;
  291.         break;
  292.     case DefAddMenu:
  293.         result = ShowAddMenu(dwID, ppt, pcmdtReserved, pdispReserved);
  294.         break;

  295.     case CustomMenu:            // 自定义菜单
  296.         if(dwID != CONTEXT_MENU_TEXTSELECT)
  297.             result = OnShowCustomContextMenu(ppt, pcmdtReserved, pdispReserved);
  298.         break;
  299.     }

  300.     return result;
  301. }

  302. HRESULT CHtmlCtrl::OnGetOverrideKeyPath(LPOLESTR * pchKey, DWORD dw)
  303. {
  304.     return S_OK;
  305. }



  306. #define CheckSwitchTrace(_X)    /
  307.     case _X:/
  308.     HCT_TRACE("OnAmbientProperty:" #_X "/n");


  309. BOOL    CHtmlCtrl::OnAmbientProperty(COleControlSite* pSite, DISPID dispid, VARIANT* pvar)
  310. {
  311.     BOOL    bRetVal;
  312.     _variant_t        vtVal;
  313.     _bstr_t            bStrAgent;


  314.     switch(dispid)
  315.     {
  316.         //    普通,编辑模式
  317.         CheckSwitchTrace(DISPID_AMBIENT_USERMODE);
  318.         break;
  319.         //    离线检测
  320.         CheckSwitchTrace(DISPID_AMBIENT_OFFLINEIFNOTCONNECTED);
  321.         break;
  322.         //    
  323.         CheckSwitchTrace(DISPID_AMBIENT_SILENT);
  324.         break;
  325.         //    文件下载控制
  326.         CheckSwitchTrace(DISPID_AMBIENT_DLCONTROL);
  327.         break;
  328.         //    用户标记
  329.         CheckSwitchTrace(DISPID_AMBIENT_USERAGENT);
  330.         bStrAgent = "TinyIE1.0";
  331.         vtVal = bStrAgent;
  332.         *pvar = vtVal.Detach();
  333.         return TRUE;
  334.         break;
  335.         //    调色板
  336.         CheckSwitchTrace(DISPID_AMBIENT_PALETTE);
  337.         break;
  338.     default:
  339.         TRACE("OnAmbientProperty: %08X/n", dispid);
  340.     }
  341.     
  342.     bRetVal = CHtmlView::OnAmbientProperty(pSite, dispid, pvar);

  343.     return bRetVal;
  344. }

  345. #define IDS_MESSAGE_BOX_TITLE 2213

  346. HRESULT CHtmlCtrl::OnShowMessage(HWND hwnd,LPOLESTR lpstrText,LPOLESTR lpstrCaption,DWORD dwType,LPOLESTR lpstrHelpFile,DWORD dwHelpContext,LRESULT * plResult)
  347. {
  348.     // 窗口标题"Microsoft Internet Explorer"的资源标识

  349.     //载入Shdoclc.dll 和IE消息框标题字符串
  350.     HINSTANCE hinstSHDOCLC = LoadLibrary(TEXT("SHDOCLC.DLL"));
  351.     if (hinstSHDOCLC == NULL)
  352.         return S_FALSE;

  353.     CString strBuf,strCaption(lpstrCaption);
  354.     strBuf.LoadString(hinstSHDOCLC, IDS_MESSAGE_BOX_TITLE);

  355.     // 比较IE消息框标题字符串和lpstrCaption
  356.     // 如果相同,用自定义标题替换
  357.     if(strBuf==lpstrCaption)
  358.         strCaption = m_DefaultMsgBoxTitle;

  359.     // 创建自己的消息框并且显示
  360.     *plResult = MessageBox(CString(lpstrText), strCaption, dwType);

  361.     //卸载Shdoclc.dll并且返回
  362.     FreeLibrary(hinstSHDOCLC);

  363.     return S_OK;
  364. }


  365. HRESULT CHtmlCtrl::OnShowCustomContextMenu(LPPOINT ppt, LPUNKNOWN pcmdtReserved,LPDISPATCH pdispReserved)
  366. {
  367.     return S_OK;
  368. }


  369. #define IDR_BROWSE_CONTEXT_MENU        24641
  370. #define IDR_FORM_CONTEXT_MENU        24640
  371. #define SHDVID_GETMIMECSETMENU        27
  372. #define SHDVID_ADDMENUEXTENSIONS    53


  373. BOOL    CHtmlCtrl::GetDefaultMenu(DWORD dwID, IUnknown *pcmdTarget, CMenu **ppMenu)
  374. {
  375.     CMenu *            pMenu;
  376.     HMENU            hMenu;
  377.     HRESULT            hr;
  378.     HINSTANCE        hinstSHDOCLC;
  379.     MENUITEMINFO    mii = {0};
  380.     CComVariant        var, var1, var2;

  381.     CComPtr<IOleCommandTarget>    spCT;


  382.     hr = pcmdTarget->QueryInterface(IID_IOleCommandTarget, (void**)&spCT);
  383.     hinstSHDOCLC = LoadLibrary(TEXT("SHDOCLC.DLL"));
  384.     if(hinstSHDOCLC == NULL)
  385.     {
  386.         return FALSE;
  387.     }

  388.     m_DefaultMenu.DestroyMenu();
  389.     hMenu = ::LoadMenu(hinstSHDOCLC, MAKEINTRESOURCE(IDR_BROWSE_CONTEXT_MENU));
  390.     m_DefaultMenu.Attach(hMenu);
  391. //    m_DefaultMenu.LoadMenu(MAKEINTRESOURCE(IDR_BROWSE_CONTEXT_MENU));
  392.     pMenu = m_DefaultMenu.GetSubMenu(dwID);

  393.     // Get the language SubMenu
  394.     hr = spCT->Exec(&CGID_ShellDocView, SHDVID_GETMIMECSETMENU, 0, NULL, &var);
  395.     mii.cbSize = sizeof(mii);
  396.     mii.fMask = MIIM_SUBMENU;
  397.     mii.hSubMenu = (HMENU) var.byref;

  398.     // Add language SubMenu to Encoding context item
  399.     pMenu->SetMenuItemInfo(IDM_LANGUAGE, &mii, FALSE);

  400.     // Insert Shortcut Menu Extensions from registry
  401.     V_VT(&var1) = VT_INT_PTR;
  402.     V_BYREF(&var1) = pMenu->GetSafeHmenu();
  403.     V_VT(&var2) = VT_I4;
  404.     V_I4(&var2) = dwID;
  405.     hr = spCT->Exec(&CGID_ShellDocView, SHDVID_ADDMENUEXTENSIONS, 0, &var1, &var2);

  406.     // Remove View Source
  407. //    pMenu->DeleteMenu(IDM_VIEWSOURCE, MF_BYCOMMAND);//删除“查看源文件”菜单项
  408.     FreeLibrary(hinstSHDOCLC);

  409.     *ppMenu = pMenu;

  410.     return TRUE;
  411. }


  412. HRESULT    CHtmlCtrl::ShowAddMenu(DWORD dwID, POINT *ppt, IUnknown *pcmdTarget, LPDISPATCH pdispReserved)
  413. {
  414.     HRESULT            hr;
  415.     HWND            hwnd;
  416.     CMenu *            pPopMenu;
  417.     CMenu *            pAddMenu;
  418.     CMenu            AddMenu;
  419.     BOOL            bRetVal;
  420.     CHtmMneuWnd        IeMenWnd(this);
  421.     CWnd *            pIEWnd;
  422.     CString            cStrText;

  423.     CComPtr<IOleWindow>            spWnd;

  424.     hr = pcmdTarget->QueryInterface(IID_IOleWindow, (void**)&spWnd);
  425.     hr = spWnd->GetWindow(&hwnd);//取得浏览器窗口句柄
  426.     pIEWnd = CWnd::FromHandle(hwnd);

  427.     bRetVal = GetDefaultMenu(dwID, pcmdTarget, &pPopMenu);
  428.     if(bRetVal == FALSE)
  429.         return S_OK;

  430.     AddMenu.LoadMenu(m_uAddMenuID);
  431.     AddMenu.GetMenuString(0, cStrText, MF_BYPOSITION);
  432.     pAddMenu = AddMenu.GetSubMenu(0);

  433.     //    OnInsertMenuAddMenu(dwID, pAddMenu);
  434.     //    pPopMenu->InsertMenu(0, MF_POPUP | MF_BYPOSITION, (UINT)pAddMenu->GetSafeHmenu(), cStrText);

  435.     IeMenWnd.SetActionMenu(pPopMenu, pAddMenu, cStrText);
  436.     IeMenWnd.SubclassWindow(hwnd);

  437.     int iSelection = pPopMenu->TrackPopupMenu(
  438.         TPM_LEFTALIGN | TPM_RIGHTBUTTON | TPM_RETURNCMD, //返回用户选择的菜单命令ID
  439.         ppt->x,    ppt->y,    pIEWnd);

  440.     pPopMenu->DeleteMenu(0, MF_BYPOSITION);

  441. //    Send selected shortcut menu item command to shell

  442.     m_pMenuNtyWnd->SendMessage(WM_COMMAND, iSelection, NULL);

  443.     SendMessage(WM_COMMAND, iSelection, NULL);

  444.     //发送到Internet Explorer_Server进行内部处理。
  445.     LRESULT lr = ::SendMessage(hwnd, WM_COMMAND, iSelection, NULL);


  446.     pIEWnd->Detach();
  447.     IeMenWnd.UnsubclassWindow();
  448.     return S_OK;

  449. }


  450. void CHtmlCtrl::OnInitAddMenu(CMenu* pPopupMenu, UINT nIndex)
  451. {
  452.     if(m_pAddMenuTarget)
  453.     {
  454.         (m_pAddMenuTarget->*m_AddMenuProc)(pPopupMenu, nIndex);
  455.     }

  456.     return;
  457. }
  458. //    新加虚函数    结束
  459. //////////////////////////////////////////////////////////////////////////////////////////////


  460. IMPLEMENT_DYNAMIC(CHtmMneuWnd, CWnd)
  461. BEGIN_MESSAGE_MAP(CHtmMneuWnd, CWnd)
  462.     ON_WM_INITMENUPOPUP()
  463. END_MESSAGE_MAP()

  464. /*
  465. CHtmMneuWnd::CHtmMneuWnd()
  466. {

  467. }

  468. CHtmMneuWnd::CHtmMneuWnd(CHtmlCtrl *pHtmCtrl)
  469. {
  470.     m_pHtmCtrl = pHtmCtrl;
  471. }

  472. CHtmMneuWnd::~CHtmMneuWnd()
  473. {

  474. }

  475. BOOL    CHtmMneuWnd::SetEnableList(CDWordArray &IdList)
  476. {
  477.     m_IdList.Copy(IdList);
  478.     return TRUE;
  479. }

  480. BOOL    CHtmMneuWnd::AddEnableId(DWORD nId)
  481. {
  482.     m_IdList.Add(nId);
  483.     return TRUE;
  484. }

  485. BOOL    CHtmMneuWnd::AddEnableId(CMenu *pMenu)
  486. {
  487.     int            nCount;
  488.     int            i;
  489.     int            nID;

  490.     nCount = pMenu->GetMenuItemCount();
  491.     for(i=0; i<nCount; i++)
  492.     {
  493.         nID = pMenu->GetMenuItemID(i);
  494.         AddEnableId(nID);
  495.     }

  496.     return TRUE;
  497. }

  498. BOOL    CHtmMneuWnd::SetHtmCtrl(CHtmlCtrl *pHtmCtrl)
  499. {
  500.     m_pHtmCtrl = pHtmCtrl;
  501.     return TRUE;
  502. }

  503. void CHtmMneuWnd::OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu)
  504. {
  505.     CWnd::OnInitMenuPopup(pPopupMenu, nIndex, bSysMenu);

  506.     int                i;
  507.     BOOL            bRetVal;

  508.     pPopupMenu->AppendMenu(MF_STRING, 34534, "345346");

  509.     for(i=0; i<m_IdList.GetSize(); i++)
  510.     {
  511. //        pPopupMenu->InsertMenu()
  512.         pPopupMenu->EnableMenuItem(m_IdList[i], MF_BYCOMMAND | MF_ENABLED);
  513. //        pPopupMenu->CheckMenuItem(m_IdList[i], TRUE);
  514.     }

  515. }

  516. */


  517. /////////////////////////////////////////////////////////////////////////////
  518. //                CHtmlNewWndWatch
  519. /////////////////////////////////////////////////////////////////////////////
  520. CHtmlNewWndWatch *    CHtmlNewWndWatch::s_pOnceInstance = NULL;

  521. IMPLEMENT_DYNAMIC(CHtmlNewWndWatch, CHtmlView)
  522. CHtmlNewWndWatch::CHtmlNewWndWatch()
  523. {
  524. }


  525. CHtmlNewWndWatch::CHtmlNewWndWatch(CHtmlCtrl *pParent)
  526. {
  527.     m_pHtmlCtrl = pParent;
  528. }


  529. CHtmlNewWndWatch *    CHtmlNewWndWatch::CreateNewWatch(CHtmlCtrl *pParent)
  530. {
  531.     if(s_pOnceInstance == NULL)
  532.     {
  533.         s_pOnceInstance = new CHtmlNewWndWatch(pParent);
  534.         s_pOnceInstance->Create(NULL,
  535.             NULL,
  536.             (WS_CHILD | WS_VISIBLE ),
  537.             CRect(0, 0, 0, 0),
  538.             pParent->GetParent(),
  539.             0,
  540.             NULL);

  541.         atexit(DeleteWatch);
  542.     }

  543.     return s_pOnceInstance;
  544. }


  545. VOID    CHtmlNewWndWatch::DeleteWatch()
  546. {
  547.     if(s_pOnceInstance)
  548.     {
  549. //        delete s_pOnceInstance;
  550.     }
  551. }


  552. CHtmlNewWndWatch::~CHtmlNewWndWatch()
  553. {

  554. }

  555. void CHtmlNewWndWatch::OnBeforeNavigate2(LPCTSTR lpszURL,
  556.                                          DWORD nFlags,
  557.                                          LPCTSTR lpszTargetFrameName,
  558.                                          CByteArray& baPostedData,
  559.                                          LPCTSTR lpszHeaders,
  560.                                          BOOL* pbCancel)
  561. {
  562.     if(m_pHtmlCtrl)
  563.         m_pHtmlCtrl->OnWatchNewWind(lpszURL);
  564.     *pbCancel = TRUE;
  565.     return;
  566. }


  567. ///////////////////////////////////////////////////////////////////////////////////////////////
  568. //            CHtmControlSite
  569. ///////////////////////////////////////////////////////////////////////////////////////////////



  570. #if _MFC_VER >= 0x0700
  571. #include <afxocc.h>
  572. #else
  573. #ifdef _AFXDLL
  574. #undef AFX_DATA
  575. #define AFX_DATA AFX_DATA_IMPORT
  576. #endif
  577. #include <../src/occimpl.h>
  578. #ifdef _AFXDLL
  579. #undef AFX_DATA
  580. #define AFX_DATA AFX_DATA_EXPORT
  581. #endif
  582. #endif

  583. #include <mshtmhst.h>

  584. BEGIN_INTERFACE_MAP(CHtmControlSite, COleControlSite)
  585.     INTERFACE_PART(CHtmControlSite, IID_IDocHostShowUI, DocHostShowUI)
  586.     INTERFACE_PART(CHtmControlSite, IID_IDocHostUIHandler, DocHostUIHandler)
  587. #if (_WIN32_IE >= 0x0501) // IE 5.5 and higher
  588.     INTERFACE_PART(CHtmControlSite, IID_IDocHostUIHandler2, DocHostUIHandler2)
  589. #endif
  590.     INTERFACE_PART(CHtmControlSite, IID_IInternetSecurityManager, InternetSecurityManager)
  591.     INTERFACE_PART(CHtmControlSite, IID_IServiceProvider, ServiceProvider)
  592.     INTERFACE_PART(CHtmControlSite, IID_IDispatch, MyAmbientProps)
  593. END_INTERFACE_MAP()

  594. CHtmControlSite::CHtmControlSite(COleControlContainer * pOcc, CHtmlCtrl* pView)
  595. : COleControlSite( pOcc )
  596. {
  597.     m_pView = pView;
  598. }

  599. CHtmControlSite::~CHtmControlSite()
  600. {
  601. }

  602. ULONG CHtmControlSite::XDocHostShowUI::AddRef()
  603. {
  604.     METHOD_PROLOGUE(CHtmControlSite, DocHostShowUI);

  605.     return pThis->ExternalAddRef();
  606. }

  607. ULONG CHtmControlSite::XDocHostShowUI::Release()
  608. {
  609.     METHOD_PROLOGUE(CHtmControlSite, DocHostShowUI);

  610.     return pThis->ExternalRelease();
  611. }

  612. HRESULT CHtmControlSite::XDocHostShowUI::QueryInterface(REFIID riid, void ** ppvObj)
  613. {
  614.     METHOD_PROLOGUE(CHtmControlSite, DocHostShowUI);

  615.     return pThis->ExternalQueryInterface( &riid, ppvObj );
  616. }

  617. HRESULT CHtmControlSite::XDocHostShowUI::ShowHelp(HWND hwnd,
  618.                                              LPOLESTR pszHelpFile,
  619.                                              UINT nCommand,
  620.                                              DWORD dwData,
  621.                                              POINT ptMouse,
  622.                                              IDispatch * pDispatchObjectHit)
  623. {
  624.     METHOD_PROLOGUE(CHtmControlSite, DocHostShowUI);

  625.     return E_NOTIMPL;
  626. }

  627. HRESULT CHtmControlSite::XDocHostShowUI::ShowMessage(HWND hwnd,
  628.                                                  LPOLESTR lpstrText,
  629.                                                  LPOLESTR lpstrCaption,
  630.                                                  DWORD dwType,
  631.                                                  LPOLESTR lpstrHelpFile,
  632.                                                  DWORD dwHelpContext,
  633.                                                  LRESULT * plResult)
  634. {
  635.     METHOD_PROLOGUE(CHtmControlSite, DocHostShowUI);

  636.     return pThis->m_pView->OnShowMessage(hwnd,lpstrText,lpstrCaption,dwType,lpstrHelpFile,dwHelpContext,plResult);
  637. }

  638. ULONG CHtmControlSite::XDocHostUIHandler::AddRef()
  639. {
  640.     METHOD_PROLOGUE(CHtmControlSite, DocHostUIHandler);
  641.     return pThis->ExternalAddRef();
  642. }

  643. ULONG CHtmControlSite::XDocHostUIHandler::Release()
  644. {
  645.     METHOD_PROLOGUE(CHtmControlSite, DocHostUIHandler);
  646.     return pThis->ExternalRelease();
  647. }

  648. HRESULT CHtmControlSite::XDocHostUIHandler::QueryInterface(REFIID riid, void ** ppvObj)
  649. {
  650.     METHOD_PROLOGUE(CHtmControlSite, DocHostUIHandler);
  651.     return pThis->ExternalQueryInterface( &riid, ppvObj );
  652. }

  653. HRESULT CHtmControlSite::XDocHostUIHandler::GetHostInfo(DOCHOSTUIINFO * pInfo)
  654. {
  655. //    pInfo->dwFlags = DOCHOSTUIFLAG_NO3DBORDER;        //去掉3D边框
  656. //    pInfo->dwFlags = DOCHOSTUIFLAG_SCROLL_NO;        //    去掉滚动条

  657.     METHOD_PROLOGUE(CHtmControlSite, DocHostUIHandler);
  658.     return pThis->m_pView->OnGetHostInfo( pInfo );
  659. }

  660. HRESULT CHtmControlSite::XDocHostUIHandler::ShowUI(DWORD dwID,
  661.                                                 IOleInPlaceActiveObject * pActiveObject,
  662.                                                 IOleCommandTarget * pCommandTarget,
  663.                                                 IOleInPlaceFrame * pFrame,
  664.                                                 IOleInPlaceUIWindow * pDoc)
  665. {
  666.     METHOD_PROLOGUE(CHtmControlSite, DocHostUIHandler);
  667.     return pThis->m_pView->OnShowUI( dwID, pActiveObject, pCommandTarget,
  668.         pFrame, pDoc );
  669. }

  670. HRESULT CHtmControlSite::XDocHostUIHandler::HideUI()
  671. {
  672.     METHOD_PROLOGUE(CHtmControlSite, DocHostUIHandler);
  673.     return pThis->m_pView->OnHideUI();
  674. }

  675. HRESULT CHtmControlSite::XDocHostUIHandler::UpdateUI()
  676. {
  677.     METHOD_PROLOGUE(CHtmControlSite, DocHostUIHandler);
  678.     return pThis->m_pView->OnUpdateUI();
  679. }

  680. HRESULT CHtmControlSite::XDocHostUIHandler::EnableModeless(BOOL fEnable)
  681. {
  682.     METHOD_PROLOGUE(CHtmControlSite, DocHostUIHandler);
  683.     return pThis->m_pView->OnEnableModeless( fEnable );
  684. }

  685. HRESULT CHtmControlSite::XDocHostUIHandler::OnDocWindowActivate(BOOL fEnable)
  686. {
  687.     METHOD_PROLOGUE(CHtmControlSite, DocHostUIHandler);
  688.     return pThis->m_pView->OnDocWindowActivate( fEnable );
  689. }

  690. HRESULT CHtmControlSite::XDocHostUIHandler::OnFrameWindowActivate(BOOL fEnable)
  691. {
  692.     METHOD_PROLOGUE(CHtmControlSite, DocHostUIHandler);
  693.     return pThis->m_pView->OnFrameWindowActivate( fEnable );
  694. }

  695. HRESULT CHtmControlSite::XDocHostUIHandler::ResizeBorder(LPCRECT prcBorder,
  696.                                                      IOleInPlaceUIWindow * pUIWindow,
  697.                                                      BOOL fFrameWindow)
  698. {
  699.     METHOD_PROLOGUE(CHtmControlSite, DocHostUIHandler);
  700.     return pThis->m_pView->OnResizeBorder( prcBorder, pUIWindow, fFrameWindow );
  701. }

  702. HRESULT CHtmControlSite::XDocHostUIHandler::ShowContextMenu(DWORD dwID,
  703.                                                          POINT * ppt,
  704.                                                          IUnknown * pcmdtReserved,
  705.                                                          IDispatch * pdispReserved)
  706. {
  707.     METHOD_PROLOGUE(CHtmControlSite, DocHostUIHandler);
  708.     return pThis->m_pView->OnShowContextMenu( dwID, ppt, pcmdtReserved,
  709.         pdispReserved );
  710. }

  711. HRESULT CHtmControlSite::XDocHostUIHandler::TranslateAccelerator(LPMSG lpMsg,
  712.                                                              const GUID * pguidCmdGroup,
  713.                                                              DWORD nCmdID)
  714. {
  715.     METHOD_PROLOGUE(CHtmControlSite, DocHostUIHandler);
  716.     return E_NOTIMPL;
  717.     return pThis->m_pView->OnTranslateAccelerator( lpMsg,
  718.         pguidCmdGroup, nCmdID );
  719. }

  720. HRESULT CHtmControlSite::XDocHostUIHandler::GetOptionKeyPath(LPOLESTR * pchKey,
  721.                                                          DWORD dw)
  722. {
  723.     METHOD_PROLOGUE(CHtmControlSite, DocHostUIHandler);
  724.     return pThis->m_pView->OnGetOptionKeyPath( pchKey, dw );
  725. }

  726. HRESULT CHtmControlSite::XDocHostUIHandler::GetDropTarget(IDropTarget * pDropTarget,
  727.                                                      IDropTarget ** ppDropTarget)
  728. {
  729.     METHOD_PROLOGUE(CHtmControlSite, DocHostUIHandler);
  730.     return pThis->m_pView->OnGetDropTarget( pDropTarget, ppDropTarget );
  731. }

  732. HRESULT CHtmControlSite::XDocHostUIHandler::GetExternal(IDispatch ** ppDispatch)
  733. {
  734.     METHOD_PROLOGUE(CHtmControlSite, DocHostUIHandler);
  735.     return pThis->m_pView->OnGetExternal( ppDispatch );
  736. }

  737. HRESULT CHtmControlSite::XDocHostUIHandler::TranslateUrl(DWORD dwTranslate,
  738.                                                      OLECHAR * pchURLIn,
  739.                                                      OLECHAR ** ppchURLOut)
  740. {
  741.     METHOD_PROLOGUE(CHtmControlSite, DocHostUIHandler);
  742.     return pThis->m_pView->OnTranslateUrl( dwTranslate, pchURLIn, ppchURLOut );
  743. }

  744. HRESULT CHtmControlSite::XDocHostUIHandler::FilterDataObject(IDataObject * pDO,
  745.                                                          IDataObject ** ppDORet)
  746. {
  747.     METHOD_PROLOGUE(CHtmControlSite, DocHostUIHandler);
  748.     return pThis->m_pView->OnFilterDataObject( pDO, ppDORet );
  749. }

  750. #if (_WIN32_IE >= 0x0501) // IE 5.5 and higher

  751. ULONG CHtmControlSite::XDocHostUIHandler2::AddRef()
  752. {
  753.     METHOD_PROLOGUE(CHtmControlSite, DocHostUIHandler2);

  754.     return pThis->ExternalAddRef();
  755. }

  756. ULONG CHtmControlSite::XDocHostUIHandler2::Release()
  757. {
  758.     METHOD_PROLOGUE(CHtmControlSite, DocHostUIHandler2);

  759.     return pThis->ExternalRelease();
  760. }

  761. HRESULT CHtmControlSite::XDocHostUIHandler2::QueryInterface(REFIID riid, void ** ppvObj)
  762. {
  763.     METHOD_PROLOGUE(CHtmControlSite, DocHostUIHandler2);

  764.     return pThis->ExternalQueryInterface( &riid, ppvObj );
  765. }

  766. HRESULT CHtmControlSite::XDocHostUIHandler2::GetHostInfo(DOCHOSTUIINFO *)
  767. {
  768.     ASSERT(FALSE);

  769.     return S_FALSE;
  770. }

  771. HRESULT CHtmControlSite::XDocHostUIHandler2::ShowUI(DWORD /*dwID*/,
  772.                                                  IOleInPlaceActiveObject * /*pActiveObject*/,
  773.                                                  IOleCommandTarget * /*pCommandTarget*/,
  774.                                                  IOleInPlaceFrame * /*pFrame*/,
  775.                                                  IOleInPlaceUIWindow * /*pDoc*/)
  776. {
  777.     ASSERT(FALSE);

  778.     return S_FALSE;
  779. }

  780. HRESULT CHtmControlSite::XDocHostUIHandler2::HideUI()
  781. {
  782.     ASSERT(FALSE);

  783.     return S_FALSE;
  784. }

  785. HRESULT CHtmControlSite::XDocHostUIHandler2::UpdateUI()
  786. {
  787.     ASSERT(FALSE);

  788.     return S_FALSE;
  789. }

  790. HRESULT CHtmControlSite::XDocHostUIHandler2::EnableModeless(BOOL /*fEnable*/)
  791. {
  792.     ASSERT(FALSE);

  793.     return S_FALSE;
  794. }

  795. HRESULT CHtmControlSite::XDocHostUIHandler2::OnDocWindowActivate(BOOL /*fActivate*/)
  796. {
  797.     ASSERT(FALSE);

  798.     return S_FALSE;
  799. }

  800. HRESULT CHtmControlSite::XDocHostUIHandler2::OnFrameWindowActivate(BOOL /*fActivate*/)
  801. {
  802.     ASSERT(FALSE);

  803.     return S_FALSE;
  804. }

  805. HRESULT CHtmControlSite::XDocHostUIHandler2::ResizeBorder(LPCRECT /*prcBorder*/,
  806.                                                      IOleInPlaceUIWindow* /*pUIWindow*/,
  807.                                                      BOOL /*fRameWindow*/)
  808. {
  809.     ASSERT(FALSE);

  810.     return S_FALSE;
  811. }

  812. HRESULT CHtmControlSite::XDocHostUIHandler2::ShowContextMenu(DWORD /*dwID*/,
  813.                                                          POINT* /*pptPosition*/,
  814.                                                          IUnknown* /*pCommandTarget*/,
  815.                                                          IDispatch* /*pDispatchObjectHit*/)
  816. {
  817.     ASSERT(FALSE);

  818.     return S_FALSE;
  819. }

  820. HRESULT CHtmControlSite::XDocHostUIHandler2::TranslateAccelerator(LPMSG /*lpMsg*/,
  821.                                                              const GUID * /*pguidCmdGroup*/,
  822.                                                              DWORD /*nCmdID*/)
  823. {
  824.     ASSERT(FALSE);

  825.     return S_FALSE;
  826. }

  827. HRESULT CHtmControlSite::XDocHostUIHandler2::GetOptionKeyPath(BSTR* /*pbstrKey*/, DWORD)
  828. {
  829.     ASSERT(FALSE);

  830.     return S_FALSE;
  831. }

  832. HRESULT CHtmControlSite::XDocHostUIHandler2::GetDropTarget(IDropTarget * /*pDropTarget*/,
  833.                                                         IDropTarget ** /*ppDropTarget*/)
  834. {
  835.     ASSERT(FALSE);

  836.     return S_FALSE;
  837. }

  838. HRESULT CHtmControlSite::XDocHostUIHandler2::GetExternal(IDispatch ** /*ppDispatch*/)
  839. {
  840.     ASSERT(FALSE);

  841.     return S_FALSE;
  842. }

  843. HRESULT CHtmControlSite::XDocHostUIHandler2::TranslateUrl(DWORD /*dwTranslate*/,
  844.                                                      OLECHAR * /*pchURLIn*/,
  845.                                                      OLECHAR ** /*ppchURLOut*/)
  846. {
  847.     ASSERT(FALSE);

  848.     return S_FALSE;
  849. }

  850. HRESULT CHtmControlSite::XDocHostUIHandler2::FilterDataObject(IDataObject * /*pDO*/,
  851.                                                          IDataObject ** /*ppDORet*/)
  852. {
  853.     ASSERT(FALSE);

  854.     return S_FALSE;
  855. }

  856. HRESULT CHtmControlSite::XDocHostUIHandler2::GetOverrideKeyPath(LPOLESTR * pchKey, DWORD dw)
  857. {
  858.     METHOD_PROLOGUE(CHtmControlSite, DocHostUIHandler2);

  859.     return pThis->m_pView->OnGetOverrideKeyPath( pchKey, dw );
  860. }
  861. #endif

  862. // InternetSecurityManager Methods
  863. HRESULT FAR EXPORT CHtmControlSite::XInternetSecurityManager
  864. ::QueryInterface(REFIID riid, void** ppvObj)
  865. {

  866.     METHOD_PROLOGUE(CHtmControlSite, InternetSecurityManager)
  867.         HRESULT hr = (HRESULT)pThis->ExternalQueryInterface(&riid, ppvObj);
  868.     return hr;
  869. }

  870. ULONG FAR EXPORT CHtmControlSite::XInternetSecurityManager::AddRef()
  871. {
  872.     METHOD_PROLOGUE(CHtmControlSite, InternetSecurityManager)
  873.         return pThis->ExternalAddRef();
  874. }

  875. ULONG FAR EXPORT CHtmControlSite::XInternetSecurityManager::Release()
  876. {

  877.     METHOD_PROLOGUE(CHtmControlSite, InternetSecurityManager)
  878.         return pThis->ExternalRelease();
  879. }

  880. HRESULT CHtmControlSite::XInternetSecurityManager
  881. ::SetSecuritySite (IInternetSecurityMgrSite *pSite)
  882. {
  883.     METHOD_PROLOGUE(CHtmControlSite, InternetSecurityManager)
  884.         return INET_E_DEFAULT_ACTION;
  885. }

  886. HRESULT CHtmControlSite::XInternetSecurityManager
  887. ::GetSecuritySite(IInternetSecurityMgrSite **ppSite)
  888. {

  889.     METHOD_PROLOGUE(CHtmControlSite, InternetSecurityManager)
  890.         return INET_E_DEFAULT_ACTION;
  891. }

  892. HRESULT CHtmControlSite::XInternetSecurityManager
  893. ::MapUrlToZone(LPCWSTR pwszUrl,DWORD *pdwZone,DWORD dwFlags)
  894. {
  895.     METHOD_PROLOGUE(CHtmControlSite, InternetSecurityManager)
  896.         return INET_E_DEFAULT_ACTION;
  897. }


  898. HRESULT FAR EXPORT CHtmControlSite::XInternetSecurityManager
  899. ::GetSecurityId(LPCWSTR pwszUrl,
  900.                 BYTE *pbSecurityId,
  901.                 DWORD *pcbSecurityId,
  902.                 DWORD dwReserved)
  903. {

  904.     METHOD_PROLOGUE(CHtmControlSite, InternetSecurityManager)
  905.         return INET_E_DEFAULT_ACTION;
  906. }


  907. STDMETHODIMP CHtmControlSite::XInternetSecurityManager
  908. ::ProcessUrlAction(    /* [in] */ LPCWSTR pwszUrl,
  909.                  /* [in] */ DWORD dwAction,
  910.                  /* [size_is][out] */ BYTE __RPC_FAR *pPolicy,
  911.                  /* [in] */ DWORD cbPolicy,
  912.                  /* [in] */ BYTE __RPC_FAR *pContext,
  913.                  /* [in] */ DWORD cbContext,
  914.                  /* [in] */ DWORD dwFlags,
  915.                  /* [in] */ DWORD dwReserved)
  916. {

  917.     METHOD_PROLOGUE(CHtmControlSite, InternetSecurityManager)

  918.     DWORD dwPolicy=URLPOLICY_ALLOW;

  919.     BOOL bNoActiveX=FALSE;
  920.     BOOL bNoJava=FALSE;
  921.     BOOL bNoScript=FALSE;
  922.     BOOL bCrossData=FALSE;

  923.     if (dwAction <= URLACTION_ACTIVEX_MAX && dwAction >= URLACTION_ACTIVEX_MIN)
  924.         dwPolicy = bNoActiveX ? URLPOLICY_DISALLOW : URLPOLICY_ALLOW;
  925.     else if ((dwAction <= URLACTION_JAVA_MAX && dwAction >= URLACTION_JAVA_MIN) ||
  926.         URLACTION_HTML_JAVA_RUN == dwAction)
  927.         if (bNoJava)
  928.             dwPolicy = URLPOLICY_JAVA_PROHIBIT;
  929.         else
  930.             return INET_E_DEFAULT_ACTION;
  931.     else if (dwAction <= URLACTION_SCRIPT_MAX && dwAction >= URLACTION_SCRIPT_MIN)
  932.         dwPolicy = bNoScript ? URLPOLICY_DISALLOW : URLPOLICY_ALLOW;
  933.     // !! If the compiler can't find URLACTION_CROSS_DOMAIN_DATA, make sure you are building with
  934.     // !! the latest version of the IE headers -- URLMON.H specifically -- from MSDN Downloads for the
  935.     // !! Web Workshop or the Platform SDK
  936.     else if (URLACTION_CROSS_DOMAIN_DATA == dwAction)
  937.         dwPolicy = bCrossData ? URLPOLICY_ALLOW : URLPOLICY_DISALLOW;
  938.     else
  939.         return INET_E_DEFAULT_ACTION;

  940.     if ( cbPolicy >= sizeof (DWORD))
  941.     {
  942.         *(DWORD*) pPolicy = dwPolicy;
  943.         return S_OK;
  944.     }
  945.     else
  946.     {
  947.         return S_FALSE;
  948.     }
  949. }

  950. HRESULT CHtmControlSite::XInternetSecurityManager
  951. ::QueryCustomPolicy(LPCWSTR pwszUrl,
  952.                     REFGUID guidKey,
  953.                     BYTE **ppPolicy,
  954.                     DWORD *pcbPolicy,
  955.                     BYTE *pContext,
  956.                     DWORD cbContext,
  957.                     DWORD dwReserved)
  958. {
  959.     METHOD_PROLOGUE(CHtmControlSite, InternetSecurityManager)
  960.         return INET_E_DEFAULT_ACTION;
  961. }

  962. HRESULT CHtmControlSite::XInternetSecurityManager
  963. ::SetZoneMapping(DWORD dwZone,
  964.                  LPCWSTR lpszPattern,
  965.                  DWORD dwFlags)
  966. {
  967.     METHOD_PROLOGUE(CHtmControlSite, InternetSecurityManager)
  968.         return INET_E_DEFAULT_ACTION;
  969. }

  970. HRESULT CHtmControlSite::XInternetSecurityManager
  971. ::GetZoneMappings(DWORD dwZone,
  972.                  IEnumString **ppenumString,
  973.                  DWORD dwFlags)
  974. {
  975.     METHOD_PROLOGUE(CHtmControlSite, InternetSecurityManager)
  976.         return INET_E_DEFAULT_ACTION;
  977. }


  978. // ServiceProvider Methods
  979. ULONG FAR EXPORT CHtmControlSite::XServiceProvider::AddRef()
  980. {
  981.     METHOD_PROLOGUE(CHtmControlSite, ServiceProvider)
  982.         return pThis->ExternalAddRef();
  983. }

  984. ULONG FAR EXPORT CHtmControlSite::XServiceProvider::Release()
  985. {
  986.     METHOD_PROLOGUE(CHtmControlSite, ServiceProvider)
  987.         return pThis->ExternalRelease();
  988. }

  989. HRESULT FAR EXPORT CHtmControlSite::XServiceProvider
  990. ::QueryInterface(REFIID riid,
  991.                  void** ppvObj)
  992. {
  993.     METHOD_PROLOGUE(CHtmControlSite, ServiceProvider)
  994.         HRESULT hr = (HRESULT)pThis->ExternalQueryInterface(&riid, ppvObj);
  995.     return hr;
  996. }

  997. STDMETHODIMP CHtmControlSite::XServiceProvider
  998. ::QueryService(REFGUID guidService,
  999.              REFIID riid,
  1000.              void** ppvObject)
  1001. {

  1002.     if (guidService == SID_SInternetSecurityManager &&
  1003.         riid == IID_IInternetSecurityManager)
  1004.     {
  1005.         METHOD_PROLOGUE(CHtmControlSite, ServiceProvider)
  1006.             HRESULT hr = (HRESULT)pThis->ExternalQueryInterface(&riid, ppvObject);
  1007.         return hr;
  1008.     }
  1009.     else
  1010.     {
  1011.         *ppvObject = NULL;

  1012.     }
  1013.     return E_NOINTERFACE;
  1014. }

  1015. /////////////////////////////////////////////////////////////////


  1016. STDMETHODIMP_(ULONG) CHtmControlSite::XMyAmbientProps::AddRef()
  1017. {
  1018.     METHOD_PROLOGUE_EX_(CHtmControlSite, MyAmbientProps)
  1019.         return (ULONG)pThis->InternalAddRef();
  1020. }

  1021. STDMETHODIMP_(ULONG) CHtmControlSite::XMyAmbientProps::Release()
  1022. {
  1023.     METHOD_PROLOGUE_EX_(CHtmControlSite, MyAmbientProps)
  1024.         return (ULONG)pThis->InternalRelease();
  1025. }

  1026. STDMETHODIMP CHtmControlSite::XMyAmbientProps::QueryInterface(
  1027.     REFIID iid, LPVOID* ppvObj)
  1028. {
  1029.     METHOD_PROLOGUE_EX_(CHtmControlSite, MyAmbientProps)
  1030.         return (HRESULT)pThis->InternalQueryInterface(&iid, ppvObj);
  1031. }

  1032. STDMETHODIMP CHtmControlSite::XMyAmbientProps::GetTypeInfoCount(
  1033.     unsigned int*)
  1034. {
  1035.     return E_NOTIMPL;
  1036. }

  1037. STDMETHODIMP CHtmControlSite::XMyAmbientProps::GetTypeInfo(
  1038.     unsigned int, LCID, ITypeInfo**)
  1039. {
  1040.     return E_NOTIMPL;
  1041. }

  1042. STDMETHODIMP CHtmControlSite::XMyAmbientProps::GetIDsOfNames(
  1043.     REFIID, LPOLESTR*, unsigned int, LCID, DISPID*)
  1044. {
  1045.     return E_NOTIMPL;
  1046. }

  1047. STDMETHODIMP CHtmControlSite::XMyAmbientProps::Invoke(DISPID dispidMember,REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS * pdispparams,
  1048.                  VARIANT * pvarResult, EXCEPINFO * pexcepinfo, UINT * puArgErr)
  1049. {
  1050.     HRESULT                hr;

  1051.     METHOD_PROLOGUE_EX_(CHtmControlSite, MyAmbientProps)
  1052.     hr = pThis->m_xAmbientProps.Invoke(dispidMember, riid, lcid, wFlags, pdispparams, pvarResult, pexcepinfo, puArgErr);
  1053.     return hr;
  1054.     switch (dispidMember)
  1055.     {
  1056.     case DISPID_AMBIENT_DLCONTROL:
  1057.         TRACE("XMyAmbientProps::Invoke: DISPID_AMBIENT_DLCONTROL/n");
  1058.         {
  1059.             pvarResult->vt = VT_I4;
  1060.             //                    pvarResult->lVal = DLCTL_NO_DLACTIVEXCTLS | (DLCTL_DOWNLOADONLY & ~(DLCTL_DLIMAGES | DLCTL_VIDEOS | DLCTL_BGSOUNDS));
  1061.             pvarResult->lVal = DLCTL_DLIMAGES | DLCTL_NO_SCRIPTS;    //    屏蔽脚本
  1062.             hr = S_OK;
  1063.         }
  1064.         break;
  1065.     default:
  1066.         TRACE("XMyAmbientProps::Invoke: %d/n", dispidMember);
  1067.     }

  1068.     return hr;
  1069. }

阅读(2956) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~