如何禁用HTML页面的上下文菜单

来源:互联网 发布:51单片机c语言教程视频 编辑:程序博客网 时间:2024/05/29 12:54
 适用版本 VS2005.
#ifndef HtmlCtrl_H#define HtmlCtrl_H//////////////////////////////////////////////////////////////////////////#include <AfxOle.h>#include <AfxHtml.h>#include <AtlBase.h>//////////////////////////////////////////////////////////////////////////#include "OwnerPolicy.h"//////////////////////////////////////////////////////////////////////////template <typename OwnerT>class HtmlCtrlT:public CHtmlView, public OwnerPolicy<OwnerT>{public:virtual HRESULT OnShowContextMenu(DWORD dwID, LPPOINT ppt, LPUNKNOWN pcmdtReserved, LPDISPATCH pdispReserved){return S_OK;}virtual HRESULT OnGetExternal(LPDISPATCH *lppDispatch){OwnerT *pOwner = owner();*lppDispatch = (pOwner == NULL) ? NULL : (owner()->GetIDispatch(TRUE));return S_OK;}HRESULT SetHTMLText(LPCTSTR lpszHTML){HRESULT hr = E_FAIL;COleStreamFile fileOleStream;fileOleStream.CreateMemoryStream();CString strHTML(lpszHTML);fileOleStream.Write(strHTML.GetBuffer(0), strHTML.GetLength() * sizeof(TCHAR));strHTML.ReleaseBuffer();fileOleStream.SeekToBegin();CComQIPtr<IPersistStreamInit> pPersistStreamInit(GetHtmlDocument());if (pPersistStreamInit == NULL) {Navigate(TEXT("about:blank"));}pPersistStreamInit = GetHtmlDocument();if (pPersistStreamInit) {hr = pPersistStreamInit->Load(static_cast<IStream *>(fileOleStream.GetStream()));}return hr;} virtual void PostNcDestroy(){//disable CView::PostNcDestroy(), he will call (delete this);}};//////////////////////////////////////////////////////////////////////////#endif

原创粉丝点击