如何禁用Html頁面的上下文菜單
作者:劉胤
在一次工作中,要使用到HtmlCtrl但是發現趙湘寧先生使用了子類化的方法,感覺還是不能放心,一直在尋找禁用Html頁面的上下文菜單的
HtmlCtrl,
最近,從微軟網站上找到一個實例(具體忘記了),正如趙先生說的還是用 IDocHostUIHandler 。整理如下:
#ifndef CustomControlSite_H
#define CustomControlSite_H
#include <AfxWin.h>
#include <AfxDisp.h>
#include <MsHtmHst.h>
#undef AFX_DATA
#define AFX_DATA AFX_DATA_IMPORT
#include <..\Src\OccImpl.h>
#undef AFX_DATA
#define AFX_DATA AFX_DATA_EXPORT
class CCustomControlSite : public COleControlSite
{
public:
CCustomControlSite(COleControlContainer *pContainer)
: COleControlSite(pContainer)
{
}
protected:
DECLARE_INTERFACE_MAP();
BEGIN_INTERFACE_PART(DocHostUIHandler, IDocHostUIHandler)
STDMETHOD(ShowContextMenu)(DWord dwID, POINT __RPC_FAR *PPT, IUnknown __RPC_FAR *pcmdtReserved, IDispatch __RPC_FAR
*pdispReserved);
STDMETHOD(GetHostInfo)(DOCHOSTUIINFO __RPC_FAR *pInfo);
STDMETHOD(ShowUI)(DWord dwID, IOleInPlaceActiveObject __RPC_FAR *pActiveObject, IOleCommandTarget __RPC_FAR
*pCommandTarget, IOleInPlaceFrame __RPC_FAR *pFrame, IOleInPlaceUIWindow __RPC_FAR *pDoc);
STDMETHOD(HideUI)();
STDMETHOD(UpdateUI)();
STDMETHOD(EnableModeless)(BOOL fEnable);
STDMETHOD(OnDocWindowActivate)(BOOL fEnable);
STDMETHOD(OnFrameWindowActivate)(BOOL fEnable);
STDMETHOD(ResizeBorder)(LPCRECT prcBorder, IOleInPlaceUIWindow __RPC_FAR *pUIWindow, BOOL fRameWindow);
STDMETHOD(TranslateAccelerator)(LPMSG lpMsg, const GUID __RPC_FAR *pguidCmdGroup, DWord nCmdID);
STDMETHOD(GetOptionKeyPath)(LPOLESTR __RPC_FAR *pchKey, DWord dw);
STDMETHOD(GetDropTarget)(IDropTarget __RPC_FAR *pDropTarget, IDropTarget __RPC_FAR *__RPC_FAR *ppDropTarget);
STDMETHOD(GetExternal)(IDispatch __RPC_FAR *__RPC_FAR *ppDispatch);
STDMETHOD(TranslateUrl)(DWord dwTranslate, OLECHAR __RPC_FAR *pchURLIn, OLECHAR __RPC_FAR *__RPC_FAR *ppchURLOut);
STDMETHOD(FilterDataObject)(IDataObject __RPC_FAR *pDO,