STDMETHODIMP CIEControlSite::XDocHostUIHandler::ShowContextMenu( DWORD dwID, LPPOINT ppt, LPUNKNOWN pcmdTarget, LPDISPATCH pdispReserved) { METHOD_PROLOGUE_EX_(CIEControlSite, DocHostUIHandler); return S_FALSE; // 点击右键添加到收藏夹 HWND hwnd; CComPtr<IOleCommandTarget> spCT; CComPtr<IOleWindow> spWnd; HRESULT hr = pcmdTarget->QueryInterface(IID_IOleCommandTarget, (void**)&spCT); if ( FAILED(hr) ) return S_FALSE; hr = pcmdTarget->QueryInterface(IID_IOleWindow, (void**)&spWnd); if ( FAILED(hr) ) return S_FALSE; hr = spWnd->GetWindow(&hwnd); #define ID_IE_ID_ADDFAV 2261 ::SendMessage(hwnd, WM_COMMAND, MAKEWPARAM(LOWORD(ID_IE_ID_ADDFAV), 0x0), 0 ); return S_OK; }
STDMETHODIMP CIEControlSite::XDocHostUIHandler::TranslateAccelerator( LPMSG lpMsg, const GUID* pguidCmdGroup, DWORD nCmdID) { METHOD_PROLOGUE_EX_(CIEControlSite, DocHostUIHandler); HRESULT hr = S_FALSE; if ( lpMsg ) { switch ( lpMsg->message ) { case WM_KEYDOWN: { bool bCtrlPressed = HIBYTE(GetKeyState(VK_CONTROL))!=0; bool bAltPressed = HIBYTE(GetKeyState(VK_MENU))!=0; bool bShiftPressed = HIBYTE(GetKeyState(VK_SHIFT))!=0; // Ctrl-N 会让 IE 自己打开一个 IE 窗口,该窗口无法被我们的处理函数拦截 // BUG #22839: AltGr + N (也就是 Ctrl-Alt-N)也被拦截了,在这里只拦截 Ctrl-N if ( bCtrlPressed && (!bAltPressed) && (!bShiftPressed) && ('N' == lpMsg->wParam) ) { hr = S_OK; } break; } } } return hr; }
STDMETHODIMP CIEControlSite::XOleCommandTarget::Exec( /* [unique][in] */ const GUID __RPC_FAR *pguidCmdGroup, /* [in] */ DWORD nCmdID, /* [in] */ DWORD nCmdexecopt, /* [unique][in] */ VARIANT __RPC_FAR *pvaIn, /* [unique][out][in] */ VARIANT __RPC_FAR *pvaOut ) { METHOD_PROLOGUE_EX_(CIEControlSite, OleCommandTarget); if ( pguidCmdGroup && IsEqualGUID(*pguidCmdGroup, CGID_DocHostCommandHandler)) { // 屏蔽脚本错误提示, 已测试IE9 if (nCmdID == OLECMDID_SHOWSCRIPTERROR) { // 这里只是简单屏蔽掉 // 如果要进一步处理, 参考: // 《How to handle script errors as a WebBrowser control host》 // http://support.microsoft.com/default.aspx?scid=kb;en-us;261003 (*pvaOut).vt = VT_BOOL; // Continue running scripts on the page. (*pvaOut).boolVal = VARIANT_TRUE; return S_OK; } } // 通过脚本关闭IE页面时通知父窗口 if (nCmdID == OLECMDID_CLOSE) { pThis->m_dlg->OnCloseIETab(); } return OLECMDERR_E_NOTSUPPORTED; }
STDMETHODIMP CIEControlSite::XDocHostUIHandler::ShowUI( DWORD dwID, LPOLEINPLACEACTIVEOBJECT pActiveObject, LPOLECOMMANDTARGET pCommandTarget, LPOLEINPLACEFRAME pFrame, LPOLEINPLACEUIWINDOW pDoc) { METHOD_PROLOGUE_EX_(CIEControlSite, DocHostUIHandler); return S_FALSE; }
STDMETHODIMP CWebCtrl::DocSite::XDocHostUIHandler::GetExternal(LPDISPATCH *lppDispatch) { METHOD_PROLOGUE_EX_(CWebCtrl::DocSite, DocHostUIHandler) CWebCtrl* pCtrl = pThis->GetCtrl(); *lppDispatch = pCtrl->m_pExternal; if ( *lppDispatch != NULL ) (*lppDispatch)->AddRef(); return ( *lppDispatch != NULL ) ? S_OK : S_FALSE; }
STDMETHODIMP CIEControlSite::XOleCommandTarget::QueryStatus( /* [unique][in] */ const GUID __RPC_FAR *pguidCmdGroup, /* [in] */ ULONG cCmds, /* [out][in][size_is] */ OLECMD __RPC_FAR prgCmds[ ], /* [unique][out][in] */ OLECMDTEXT __RPC_FAR *pCmdText ) { METHOD_PROLOGUE_EX_(CIEControlSite, OleCommandTarget); return OLECMDERR_E_NOTSUPPORTED; }
HRESULT CIEControlSite::XHTMLOMWindowServices::window_call(const char * methodName, LONG x, LONG y) { METHOD_PROLOGUE_EX_(CIEControlSite, HTMLOMWindowServices); HRESULT hr = S_FALSE; if ( ! pThis->m_dlg ) return S_OK; return hr; }
STDMETHODIMP CIEControlSite::XDocHostUIHandler::GetHostInfo( DOCHOSTUIINFO *pInfo) { METHOD_PROLOGUE_EX_(CIEControlSite, DocHostUIHandler); pInfo->dwFlags = DOCHOSTUIFLAG_NO3DBORDER |DOCHOSTUIFLAG_THEME |DOCHOSTUIFLAG_ENABLE_FORMS_AUTOCOMPLETE |DOCHOSTUIFLAG_LOCAL_MACHINE_ACCESS_CHECK |DOCHOSTUIFLAG_CODEPAGELINKEDFONTS; pInfo->dwDoubleClick = DOCHOSTUIDBLCLK_DEFAULT; return S_OK; }
HRESULT CIEControlSite::XHTMLOMWindowServices::window_call(const char * methodName, LONG x, LONG y) { METHOD_PROLOGUE_EX_(CIEControlSite, HTMLOMWindowServices); HRESULT hr = S_FALSE; // Suggested by Sonja's boodschappenlijst ([email protected]): // Tools -> Options -> Content -> Enable Javascript [Advanced] -> Allow scripts to “Move or resize existing windows”. if ( ! pThis->m_dlg ) return S_OK; /* if (nsConfigManager::isClassicMode || m_pParent->m_pPluginInstance->getConfigManager()->getBoolPref("dom.disable_window_move_resize")) return S_OK; HRESULT hr = E_FAIL; do { if ( ! m_pParent ) break; if ( ! m_pParent->m_pPluginInstance ) break; NPP npp = m_pParent->m_pPluginInstance->instance(); NPObject * window_object_ = NULL; if ( NPN_GetValue(npp, NPNVWindowNPObject, &window_object_) != NPERR_NO_ERROR ) break; NPIdentifier id_method = NPN_GetStringIdentifier(methodName); if ( !id_method ) break; NPVariant pt[2]; INT32_TO_NPVARIANT(x, pt[0]); INT32_TO_NPVARIANT(y, pt[1]); NPVariant result; NULL_TO_NPVARIANT(result); if ( NPN_Invoke(npp, window_object_, id_method, pt, 2, &result) ) { NPN_ReleaseVariantValue(&result); } hr = S_OK; } while(false); */ return hr; }
STDMETHODIMP COlePropertiesDialog::XOleUIObjInfo::SetViewInfo( DWORD dwObject, HGLOBAL hMetaPict, DWORD dvAspect, int nCurrentScale, BOOL bRelativeToOrig) { METHOD_PROLOGUE_EX_(COlePropertiesDialog, OleUIObjInfo) COleClientItem* pItem = (COleClientItem*)dwObject; ASSERT_VALID(pItem); // handle aspect changes if (dvAspect != -1) { pItem->OnChange(OLE_CHANGED_ASPECT, dvAspect); pItem->SetDrawAspect((DVASPECT)dvAspect); // force scale to 100% when changing aspects if (dvAspect == DVASPECT_ICON) { nCurrentScale = 100; bRelativeToOrig = TRUE; } else if (nCurrentScale == -1) { nCurrentScale = 100; bRelativeToOrig = FALSE; } } // handle icon representation changes if (hMetaPict != NULL) { pItem->SetIconicMetafile(hMetaPict); if (pItem->GetDrawAspect() == DVASPECT_ICON) pItem->OnChange(OLE_CHANGED, (DWORD)DVASPECT_ICON); } // handle scale changes if (nCurrentScale != -1) { pThis->OnApplyScale(pItem, nCurrentScale, bRelativeToOrig); } return S_OK; }
STDMETHODIMP CWebCtrl::DocSite::XDocHostUIHandler::ShowContextMenu(DWORD dwID, LPPOINT ppt, LPUNKNOWN pcmdtReserved, LPDISPATCH pdispReserved) { METHOD_PROLOGUE_EX_(CWebCtrl::DocSite, DocHostUIHandler) CWebCtrl* pCtrl = pThis->GetCtrl(); WVNCONTEXTMENU pNotify; pNotify.hdr.hwndFrom = pCtrl->GetSafeHwnd(); pNotify.hdr.idFrom = pCtrl->GetDlgCtrlID(); pNotify.hdr.code = WVN_CONTEXTMENU; pNotify.dwMenuID = dwID; pNotify.ptMouse = *ppt; pNotify.pCmdTarget = pcmdtReserved; pNotify.pContext = pdispReserved; LRESULT lResult = pCtrl->GetOwner()->SendMessage( WM_NOTIFY, (WPARAM)pNotify.hdr.idFrom, (LPARAM)&pNotify ); if ( lResult == 1 ) return S_OK; pCtrl->EnterMenu( ppt ); return S_FALSE; }
HRESULT FAR EXPORT CIEControlSite::XOleCommandTarget::QueryInterface(REFIID riid, void **ppvObj) { METHOD_PROLOGUE_EX_(CIEControlSite, OleCommandTarget); HRESULT hr = (HRESULT)pThis->ExternalQueryInterface(&riid, ppvObj); return hr; }
STDMETHODIMP CIEControlSite::XDocHostUIHandler::FilterDataObject( LPDATAOBJECT pDataObject, LPDATAOBJECT* ppDataObject) { METHOD_PROLOGUE_EX_(CIEControlSite, DocHostUIHandler); return S_FALSE; }
STDMETHODIMP CIEControlSite::XDocHostUIHandler::TranslateUrl( DWORD dwTranslate, OLECHAR* pchURLIn, OLECHAR** ppchURLOut) { METHOD_PROLOGUE_EX_(CIEControlSite, DocHostUIHandler); return S_FALSE; }
STDMETHODIMP CIEControlSite::XDocHostUIHandler::GetDropTarget( LPDROPTARGET pDropTarget, LPDROPTARGET* ppDropTarget) { METHOD_PROLOGUE_EX_(CIEControlSite, DocHostUIHandler); return S_FALSE; }
STDMETHODIMP CIEControlSite::XDocHostUIHandler::GetOptionKeyPath( LPOLESTR* pchKey, DWORD dwReserved) { METHOD_PROLOGUE_EX_(CIEControlSite, DocHostUIHandler); return S_FALSE; }
STDMETHODIMP CIEControlSite::XDocHostUIHandler::ShowContextMenu( DWORD dwID, LPPOINT ppt, LPUNKNOWN pcmdTarget, LPDISPATCH pdispReserved) { METHOD_PROLOGUE_EX_(CIEControlSite, DocHostUIHandler); return S_FALSE; }
ULONG FAR EXPORT CIEControlSite::XHTMLOMWindowServices::Release() { METHOD_PROLOGUE_EX_(CIEControlSite, OleCommandTarget); return pThis->ExternalRelease(); }
STDMETHODIMP CIEControlSite::XDocHostUIHandler::UpdateUI(void) { METHOD_PROLOGUE_EX_(CIEControlSite, DocHostUIHandler); return S_OK; }
STDMETHODIMP CIEControlSite::XHTMLOMWindowServices::QueryInterface( REFIID iid, LPVOID far* ppvObj) { METHOD_PROLOGUE_EX_(CIEControlSite, HTMLOMWindowServices); return pThis->ExternalQueryInterface(&iid, ppvObj); }
ULONG FAR EXPORT CIEControlSite::XOleCommandTarget::AddRef() { METHOD_PROLOGUE_EX_(CIEControlSite, OleCommandTarget); return pThis->ExternalAddRef(); }
STDMETHODIMP_(ULONG) CIEControlSite::XDocHostUIHandler::Release() { METHOD_PROLOGUE_EX_(CIEControlSite, DocHostUIHandler); return pThis->ExternalRelease(); }
STDMETHODIMP CIEControlSite::XDocHostUIHandler::QueryInterface( REFIID iid, LPVOID far* ppvObj) { METHOD_PROLOGUE_EX_(CIEControlSite, DocHostUIHandler); return pThis->ExternalQueryInterface(&iid, ppvObj); }
STDMETHODIMP CIEControlSite::XHTMLOMWindowServices::resizeBy(LONG x, LONG y) { METHOD_PROLOGUE_EX_(CIEControlSite, HTMLOMWindowServices); return window_call("resizeBy", x, y); }
STDMETHODIMP CIEControlSite::XDocHostUIHandler::EnableModeless(BOOL fEnable) { METHOD_PROLOGUE_EX_(CIEControlSite, DocHostUIHandler); return S_OK; }
STDMETHODIMP CIEControlSite::XDocHostUIHandler::GetExternal(LPDISPATCH *lppDispatch) { METHOD_PROLOGUE_EX_(CIEControlSite, DocHostUIHandler); return S_FALSE; }
STDMETHODIMP CIEControlSite::XHTMLOMWindowServices::moveTo(LONG x, LONG y) { METHOD_PROLOGUE_EX_(CIEControlSite, OleCommandTarget); return window_call("moveTo", x, y); }
STDMETHODIMP CIEControlSite::XDocHostUIHandler::OnFrameWindowActivate( BOOL fActivate) { METHOD_PROLOGUE_EX_(CIEControlSite, DocHostUIHandler); return S_OK; }
void COleDispatchImpl::Disconnect() { METHOD_PROLOGUE_EX_(CCmdTarget, Dispatch) pThis->ExternalDisconnect(); // always disconnect the object }
STDMETHODIMP CIEControlSite::XDocHostUIHandler::ResizeBorder( LPCRECT prcBorder, LPOLEINPLACEUIWINDOW pUIWindow, BOOL fFrameWindow) { METHOD_PROLOGUE_EX_(CIEControlSite, DocHostUIHandler); return S_OK; }