void vmsFlashHelper::DisableFlashMovies(IHTMLDocument2Ptr spDoc, BOOL bIncludingFrames) { FLASHLIST vf; GetFlashMoviesObjList (spDoc, &vf, bIncludingFrames); for (int i = 0; i < vf.size (); i++) { IHTMLElementPtr spElem (vf [i]); if (spElem) { IHTMLStylePtr spStyle; HRESULT hr = spElem->get_style (&spStyle); if (SUCCEEDED (hr) && spStyle != NULL) { spStyle->put_visibility (L"hidden"); spStyle->put_pixelHeight (0); spStyle->put_pixelWidth (0); } } } }
/****************************************************************************** * Invoke -- Takes a dispid and uses it to call another of the methods of this * class. Returns S_OK if the call was successful. ******************************************************************************/ STDMETHODIMP WebBrowserEventSinker::Invoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS* pDispParams, VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr) { //Validate arguments. if ((riid != IID_NULL)) return E_INVALIDARG; //if (dispIdMember != DISPID_STATUSTEXTCHANGE)//过于频繁的不显示了 //{ // TCHAR buf[128] = {0}; // _stprintf(buf, _T("WebBrowserEventSinker::Invoke dispId = %d\n"), dispIdMember); // TRACE(buf); //} HRESULT hr = S_OK; // Initialize. switch (dispIdMember) { //注意:pDispParams的参数和MFC的参数顺序是相反的,MFC的第一个参数是WebBrowser的this指针 //The last of pDispParams is an object that evaluates to the top-level or frame WebBrowser object corresponding to the event. // case DISPID_NEWWINDOW3: // // (IDispatch **ppDisp, VARIANT_BOOL *Cancel, DWORD dwFlags, BSTR bstrUrlContext, BSTR bstrUrl) // return E_NOTIMPL; // break; // // case DISPID_NEWWINDOW2: // // pDispParams->rgvarg[0]: BOOL* Cancel // // pDispParams->rgvarg[1]: LPDISPATCH* ppDisp, dest app // { // int nCount = pDispParams->cArgs; // _variant_t vVal = pDispParams->rgvarg[1]; // IWebBrowser2Ptr pWB = vVal.pdispVal; // AdviseWebBrowser(pWB); // } // break; // case DISPID_BEFORENAVIGATE2: // pDispParams->rgvarg[6]: WebBrowser object // pDispParams->rgvarg[5 - 0]: // (LPCTSTR lpszURL, DWORD nFlags, LPCTSTR lpszTargetFrameName, CByteArray& baPostedData, LPCTSTR lpszHeaders, BOOL* pbCancel) // { // int nCount = pDispParams->cArgs; // _variant_t vVal = pDispParams->rgvarg[nCount - 2]; // } // break; case DISPID_NAVIGATECOMPLETE2: //(LPCTSTR lpszURL) // pDispParams->rgvarg[0]: URL to navigate to - VT_BYREF|VT_VARIANT // pDispParams->rgvarg[1]: An object that evaluates to the top-level or frame WebBrowser object corresponding to the event. if (pDispParams->cArgs >= 2 && pDispParams->rgvarg[1].vt == VT_DISPATCH) SetCustomDocUIHandler(pDispParams->rgvarg[1].pdispVal); break; case DISPID_DOCUMENTCOMPLETE: //(LPCTSTR lpszURL) // pDispParams->rgvarg[0]: URL to navigate to - VT_BYREF|VT_VARIANT // pDispParams->rgvarg[1]: An object that evaluates to the top-level or frame WebBrowser object corresponding to the event. if (pDispParams->cArgs >= 2 && pDispParams->rgvarg[1].vt == VT_DISPATCH) { IWebBrowser2Ptr pBrowser; (pDispParams->rgvarg[1].pdispVal)->QueryInterface(IID_IWebBrowser2,(void**)&pBrowser); if (pBrowser) { IHTMLDocument2Ptr pDocument; IDispatchPtr spDisp; pBrowser->get_Document(&spDisp); pDocument = spDisp; if (pDocument) { IHTMLElementPtr pElement; IHTMLBodyElementPtr pBody; //IID_IHTMLBodyElement pDocument->get_body(&pElement); pBody = pElement; if (pBody != NULL) { pBody->put_scroll((BSTR)L"auto"); IHTMLStylePtr pStyle; pElement->get_style(&pStyle); pStyle->put_border((BSTR)L"none"); pStyle->put_overflow((BSTR)L"auto"); } } } } break; default: break; } return hr; }