STDMETHODIMP DuiLib::CWebBrowserUI::Invoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS* pDispParams, VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr) { if ((riid != IID_NULL)) return E_INVALIDARG; switch (dispIdMember) { case DISPID_BEFORENAVIGATE2: BeforeNavigate2( pDispParams->rgvarg[6].pdispVal, pDispParams->rgvarg[5].pvarVal, pDispParams->rgvarg[4].pvarVal, pDispParams->rgvarg[3].pvarVal, pDispParams->rgvarg[2].pvarVal, pDispParams->rgvarg[1].pvarVal, pDispParams->rgvarg[0].pboolVal); break; case DISPID_COMMANDSTATECHANGE: CommandStateChange( pDispParams->rgvarg[1].lVal, pDispParams->rgvarg[0].boolVal); break; case DISPID_NAVIGATECOMPLETE2: NavigateComplete2( pDispParams->rgvarg[1].pdispVal, pDispParams->rgvarg[0].pvarVal); break; case DISPID_NAVIGATEERROR: NavigateError( pDispParams->rgvarg[4].pdispVal, pDispParams->rgvarg[3].pvarVal, pDispParams->rgvarg[2].pvarVal, pDispParams->rgvarg[1].pvarVal, pDispParams->rgvarg[0].pboolVal); break; case DISPID_STATUSTEXTCHANGE: break; // case DISPID_NEWWINDOW2: // break; case DISPID_NEWWINDOW3: NewWindow3( pDispParams->rgvarg[4].ppdispVal, pDispParams->rgvarg[3].pboolVal, pDispParams->rgvarg[2].uintVal, pDispParams->rgvarg[1].bstrVal, pDispParams->rgvarg[0].bstrVal); break; // case DISPID_PROPERTYCHANGE: // if (pDispParams->cArgs>0 && pDispParams->rgvarg[0].vt == VT_BSTR) { // TRACE(_T("PropertyChange(%s)\n"), pDispParams->rgvarg[0].bstrVal); // } // break; default: return DISP_E_MEMBERNOTFOUND; } return S_OK; }
STDMETHODIMP DuiLib::CWebBrowserUI::Invoke( DISPID dispIdMember, REFIID riid, LCID lcid,WORD wFlags, DISPPARAMS* pDispParams,VARIANT* pVarResult, EXCEPINFO* pExcepInfo,UINT* puArgErr ) { if ((riid != IID_NULL)) return E_INVALIDARG; switch(dispIdMember) { case DISPID_BEFORENAVIGATE2: BeforeNavigate2( pDispParams->rgvarg[6].pdispVal, pDispParams->rgvarg[5].pvarVal, pDispParams->rgvarg[4].pvarVal, pDispParams->rgvarg[3].pvarVal, pDispParams->rgvarg[2].pvarVal, pDispParams->rgvarg[1].pvarVal, pDispParams->rgvarg[0].pboolVal); break; break; case DISPID_COMMANDSTATECHANGE: break; case DISPID_NAVIGATECOMPLETE2: NavigateComplete2( pDispParams->rgvarg[1].pdispVal, pDispParams->rgvarg[0].pvarVal); break; case DISPID_NAVIGATEERROR: NavigateError( pDispParams->rgvarg[4].pdispVal, pDispParams->rgvarg[3].pvarVal, pDispParams->rgvarg[2].pvarVal, pDispParams->rgvarg[1].pvarVal, pDispParams->rgvarg[0].pboolVal); break; case DISPID_STATUSTEXTCHANGE: break; // case DISPID_NEWWINDOW2: // break; case DISPID_NEWWINDOW3: NewWindow3( pDispParams->rgvarg[4].ppdispVal, pDispParams->rgvarg[3].pboolVal, pDispParams->rgvarg[2].uintVal, pDispParams->rgvarg[1].bstrVal, pDispParams->rgvarg[0].bstrVal); break; case DISPID_DOCUMENTCOMPLETE: DocumentComplete( pDispParams->rgvarg[1].pdispVal, pDispParams->rgvarg[0].pvarVal); default: return E_NOTIMPL; } return S_OK; }
STDMETHODIMP IEViewSink::Invoke(DISPID dispIdMember, REFIID, LCID, WORD, DISPPARAMS* pDispParams, VARIANT*, EXCEPINFO*, UINT*) { if (!pDispParams) return E_INVALIDARG; switch (dispIdMember) { case DISPID_BEFORENAVIGATE2: BeforeNavigate2(pDispParams->rgvarg[6].pdispVal, pDispParams->rgvarg[5].pvarVal, pDispParams->rgvarg[4].pvarVal, pDispParams->rgvarg[3].pvarVal, pDispParams->rgvarg[2].pvarVal, pDispParams->rgvarg[1].pvarVal, pDispParams->rgvarg[0].pboolVal); return S_OK; } return DISP_E_MEMBERNOTFOUND; }
STDMETHODIMP DWebBrowserEventsImpl::Invoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr) { switch (dispIdMember) { ///////////////////////////////////////////////////////// // The parameters for this DISPID are as follows: // [0]: Cancel flag - VT_BYREF|VT_BOOL // [1]: IDispatch* - Pointer to an IDispatch interface. // You can set this parameter to the IDispatch of // a WebBrowser Control that you've created. When // you pass back an IDispatch like this, MSHTML will // use the control you've given it to open the link. // case DISPID_NEWWINDOW2: { NewWindow2(pDispParams->rgvarg[1].ppdispVal, pDispParams->rgvarg[0].pboolVal); } break; /////////////////////////////////////////////////////////// // The parameters for this DISPID are as follows: // [0]: Cancel flag - VT_BYREF|VT_BOOL // [1]: HTTP headers - VT_BYREF|VT_VARIANT // [2]: Address of HTTP POST data - VT_BYREF|VT_VARIANT // [3]: Target frame name - VT_BYREF|VT_VARIANT // [4]: Option flags - VT_BYREF|VT_VARIANT // [5]: URL to navigate to - VT_BYREF|VT_VARIANT // [6]: An object that evaluates to the top-level or frame // WebBrowser object corresponding to the event. // // User clicked a link or launched the browser. // case DISPID_BEFORENAVIGATE2: { BeforeNavigate2(pDispParams->rgvarg[6].pdispVal, pDispParams->rgvarg[5].pvarVal, pDispParams->rgvarg[4].pvarVal, pDispParams->rgvarg[3].pvarVal, pDispParams->rgvarg[2].pvarVal, pDispParams->rgvarg[1].pvarVal, pDispParams->rgvarg[0].pboolVal); } break; /////////////////////////////////////////////////////////// // The parameters for this DISPID: // [0]: URL navigated to - VT_BYREF|VT_VARIANT // [1]: An object that evaluates to the top-level or frame // WebBrowser object corresponding to the event. // // Fires after a navigation to a link is completed on either // a window or frameSet element. // case DISPID_NAVIGATECOMPLETE2: { NavigateComplete2(pDispParams->rgvarg[1].pdispVal, pDispParams->rgvarg[0].pvarVal); // Check if m_lpDocCompleteDisp is NULL. If NULL, that means it is // the top level NavigateComplete2. Save the LPDISPATCH if (!m_lpDocCompleteDisp) { VARIANTARG varDisp = pDispParams->rgvarg[1]; m_lpDocCompleteDisp = varDisp.pdispVal; } } break; /////////////////////////////////////////////////////////// // The parameters for this DISPID: // [0]: New status bar text - VT_BSTR // case DISPID_STATUSTEXTCHANGE: { StatusTextChange(pDispParams->rgvarg[0].bstrVal); } break; /////////////////////////////////////////////////////////// // The parameters for this DISPID: // [0]: Maximum progress - VT_I4 // [1]: Amount of total progress - VT_I4 // case DISPID_PROGRESSCHANGE: { ProgressChange(pDispParams->rgvarg[1].intVal, pDispParams->rgvarg[0].intVal); } break; /////////////////////////////////////////////////////////// // The parameters for this DISPID: // [0]: URL navigated to - VT_BYREF|VT_VARIANT // [1]: An object that evaluates to the top-level or frame // WebBrowser object corresponding to the event. // // Fires when a document has been completely loaded and initialized. // Unreliable -- currently, the DWebBrowserEvents2::DocumentComplete // does not fire when the IWebBrowser2::Visible property of the // WebBrowser Control is set to false (see Q259935). Also, multiple // DISPID_DOCUMENTCOMPLETE events can be fired before the final // READYSTATE_COMPLETE (see Q180366). // case DISPID_DOCUMENTCOMPLETE: { DocumentComplete(pDispParams->rgvarg[1].pdispVal, pDispParams->rgvarg[0].pvarVal); VARIANTARG varDisp = pDispParams->rgvarg[1]; if (m_lpDocCompleteDisp && m_lpDocCompleteDisp == varDisp.pdispVal) { // if the LPDISPATCH are same, that means // it is the final DocumentComplete. Reset m_lpDocCompleteDisp m_lpDocCompleteDisp = NULL; // Handle new doc. DocumentReallyComplete(pDispParams->rgvarg[1].pdispVal, pDispParams->rgvarg[0].pvarVal); } } break; /////////////////////////////////////////////////////////// // No parameters // // Fires when a navigation operation is beginning. // case DISPID_DOWNLOADBEGIN: DownloadBegin(); break; /////////////////////////////////////////////////////////// // No parameters // // Fires when a navigation operation finishes, is halted, or fails. // case DISPID_DOWNLOADCOMPLETE: DownloadComplete(); break; /////////////////////////////////////////////////////////// // The parameters for this DISPID: // [0]: Enabled state - VT_BOOL // [1]: Command identifier - VT_I4 // case DISPID_COMMANDSTATECHANGE: { CommandStateChange(pDispParams->rgvarg[1].intVal, pDispParams->rgvarg[0].boolVal); } break; /////////////////////////////////////////////////////////// // The parameters for this DISPID: // [0]: Document title - VT_BSTR // [1]: An object that evaluates to the top-level or frame // WebBrowser object corresponding to the event. // case DISPID_TITLECHANGE: { TitleChange(pDispParams->rgvarg[0].bstrVal); } break; /////////////////////////////////////////////////////////// // The parameters for this DISPID: // [0]: Name of property that changed - VT_BSTR // case DISPID_PROPERTYCHANGE: { PropertyChange(pDispParams->rgvarg[0].bstrVal); } break; /////////////////////////////////////////////////////////// // The parameters for this DISPID: // [0]: Cancel flag - VT_BYREF|VT_BOOL // [1]: Child Window (created from script) - VT_BOOL // // case DISPID_WINDOWCLOSING: { WindowClosing(pDispParams->rgvarg[1].boolVal, pDispParams->rgvarg[0].pboolVal); } break; /////////////////////////////////////////////////////////// // The parameters for this DISPID: // [0]: Cancel flag - VT_BYREF|VT_BOOL // // case DISPID_FILEDOWNLOAD: { FileDownload(pDispParams->rgvarg[0].pboolVal); } break; /////////////////////////////////////////////////////////// // The parameters for this DISPID are as follows: // [0]: Cancel flag - VT_BYREF|VT_BOOL // [1]: Error status code - VT_BYREF|VT_VARIANT // [2]: Target frame name - VT_BYREF|VT_VARIANT // [3]: URL where navigate failed - VT_BYREF|VT_VARIANT // [4]: An object that evaluates to the top-level or frame // WebBrowser object corresponding to the event. // // case DISPID_NAVIGATEERROR: { NavigateError(pDispParams->rgvarg[4].pdispVal, pDispParams->rgvarg[3].pvarVal, pDispParams->rgvarg[2].pvarVal, pDispParams->rgvarg[1].pvarVal, pDispParams->rgvarg[0].pboolVal); m_lpDocCompleteDisp = NULL; } break; /////////////////////////////////////////////////////////// // The parameters for this DISPID: // [0]: Visible - VT_BOOL // case DISPID_ONVISIBLE: { OnVisible(pDispParams->rgvarg[0].boolVal); } break; /////////////////////////////////////////////////////////// // No parameters // // The BHO docs in MSDN say to use DISPID_QUIT, but this is an error. // The BHO never gets a DISPID_QUIT and thus the browser connection // never gets unadvised and so the BHO never gets the FinalRelease(). // This is bad. So use DISPID_ONQUIT instead and everything is cool -- // EXCEPT when you exit the browser when viewing a page that launches // a popup in the onunload event! In that case the BHO is already // unadvised so it does not intercept the popup. So the trick is to // navigate to a known page (I used the about:blank page) that does // not have a popup in the onunload event before unadvising. // case DISPID_ONQUIT: OnQuit(); break; default: { } break; } return NOERROR; }