Display the web page in the dialog, and block the pop-up menu of IE

zhaozj2021-02-11  179

In the dialog box is not a fresh topic, but to remove the pop-up menu of IE, it is not easy, there may be many programmers have made trials, obviously, capture WM_RBUTTONDOWN , WM_RBUTTONUP, WM_CONTEXTMENU, message, and heavy duty PretranslateMessage can not achieve good results. All this is related to the IE's extension interface IDochostuiHandler, which does not want to tell this interface in detail, just this need to remove the pop-up menu, use an example as an annotation. First, implement chtmlctrl. CHTMLCTRL This class is an essential for using the ChtmlView display web page in the dialog. In fact, it is very simple, just pay attention to the following points: 1. Delivered from ChtmlView. 2. Constructing the function. PUBLIC, because the constructor of the ChtmlView is Protect. 3. The captured WM_MOUSEACTIVATE message, as follows: int CHtmlCtrl :: OnMouseActivate (CWnd * pDesktopWnd, UINT nHitTest, UINT message) {return CWnd :: OnMouseActivate (pDesktopWnd, nHitTest, message); ^^^^ Note: not CHtmlView} 4 weight. Carry postncdestroy and nothing. OK, no problem, you can now declare the chtmlctrl variable in the dialog, and create, navigate, now the web page is displayed, the next step. Second, write a strange, a bit of a C class (CMYUI) like a COM class object. #include class cmyui: public idochostuihandler {public: BOOL M_VBENABLECTXMENUS; CMYUI (): m_vbenablectXMenus (false) {} // false means not displaying pop-up menu Virtual ~ cmyui ()}

STDMETHOD (ShowContextMenu) (DWORD dwID, POINT FAR * ppt, IUnknown FAR * pcmdtReserved, IDispatch FAR * pdispReserved) {if (m_vbEnableCtxMenus == TRUE) // Show Context Menu return S_FALSE; else return S_OK;} STDMETHOD (GetHostInfo) (DOCHOSTUIINFO FAR * pInfo) {return E_NOTIMPL;} STDMETHOD (ShowUI) (DWORD dwID, IOleInPlaceActiveObject FAR * pActiveObject, IOleCommandTarget FAR * pCommandTarget, IOleInPlaceFrame FAR * pFrame, IOleInPlaceUIWindow FAR * pDoc) {return E_NOTIMPL;} STDMETHOD (HideUI) (void) { return E_NOTIMPL;} STDMETHOD (UpdateUI) (void) {return E_NOTIMPL;} STDMETHOD (EnableModeless) (BOOL fEnable) {return E_NOTIMPL;} STDMETHOD (OnDocWindowActivate) (BOOL fActivate) {return E_NOTIMPL;} STDMETHOD (OnFrameWindowActivate) (BOOL fActivate) {RETURN E_NOTIMPL;} stdmethod (Resize Border) (LPCRECT prcBorder, IOleInPlaceUIWindow FAR * pUIWindow, BOOL fRameWindow) {return E_NOTIMPL;} STDMETHOD (TranslateAccelerator) (LPMSG lpMsg, const GUID FAR * pguidCmdGroup, DWORD nCmdID) {

转载请注明原文地址:https://www.9cbs.com/read-5694.html

New Post(0)