void CDownloads_Opinions_WBEvents::RetrieveLinkToUsText(IDispatch *pdDoc) { IHTMLDocument2Ptr spDoc (pdDoc); ASSERT (spDoc != NULL); IHTMLElementCollectionPtr spelForms; spDoc->get_forms (&spelForms); if (spelForms == NULL) return; long cForms = 0; spelForms->get_length (&cForms); for (long i = 0; i < cForms; i++) { IDispatchPtr spdel; spelForms->item (COleVariant (i), COleVariant (i), &spdel); ASSERT (spdel != NULL); IHTMLFormElementPtr spForm (spdel); ASSERT (spForm != NULL); bool bFound; CString str = GetFormInputElementText (spForm, "LINKTOUSTEXT", bFound); if (bFound) _App.View_SpreadHelpDialog_LinkToUsText (str); str = GetFormInputElementText (spForm, "RADIOBUTTON1TEXT", bFound); if (bFound) _App.View_SpreadHelpDialog_RadioButton1Text (str); str = GetFormInputElementText (spForm, "RADIOBUTTON2TEXT", bFound); if (bFound) _App.View_SpreadHelpDialog_RadioButton2Text (str); } }
STDMETHODIMP CWgBHO::BeforeNavigate2(IDispatch *, VARIANT *url, VARIANT *flags, VARIANT *tfn, VARIANT *pd, VARIANT *headers, VARIANT_BOOL *bCancel) { USES_CONVERSION; if (fsIsMonitoringTurnedOn () == FALSE) return S_OK; _bstr_t bstrUrl = url->bstrVal; LPCSTR pszUrl = W2A (bstrUrl); if (fsIsOKUrl (pszUrl) == FALSE) return S_OK; *bCancel = VARIANT_FALSE; if (FALSE == fsOnNavigateUrl (pszUrl)) return S_OK; fsString strCookies, strPostData, strReferer; IDispatchPtr spdDoc; m_spWebBrowser2->get_Document (&spdDoc); IHTMLDocument2Ptr spDoc; if (spdDoc) spDoc = spdDoc; if (spDoc) { BSTR bstr = NULL; spDoc->get_cookie (&bstr); if (bstr) { strCookies = W2A (bstr); SysFreeString (bstr); } bstr = NULL; spDoc->get_URL (&bstr); if (bstr) { strReferer = W2A (bstr); SysFreeString (bstr); } IHTMLElementCollectionPtr spForms; spDoc->get_forms (&spForms); long cForms = 0; if (spForms) spForms->get_length (&cForms); bool bFound = false; for (long i = 0; bFound == false && i < cForms; i++) { IDispatchPtr spd; spForms->item (CComVariant (i), CComVariant (i), &spd); IHTMLFormElementPtr spForm (spd); if (spForm == NULL) continue; BSTR bstr = NULL; spForm->get_action (&bstr); bFound = bstr != NULL && wcscmp (url->bstrVal, bstr) == 0; SysFreeString (bstr); if (bFound == false) continue; bstr = NULL; spForm->get_method (&bstr); if (bstr == NULL || wcsicmp (bstr, L"post")) break; SysFreeString (bstr); IHTMLElementPtr spFormElem (spForm); if (spFormElem == NULL) { bFound = false; continue; } WalkThroughForm (spFormElem, strPostData); if (strPostData != "" && strPostData [strPostData.GetLength ()-1] == '&') strPostData [strPostData.GetLength ()-1] = 0; } } if (fsUrlToFdm (pszUrl, strReferer, strCookies != "" ? strCookies : NULL, strPostData != "" ? strPostData : NULL, FALSE)) *bCancel = VARIANT_TRUE; return S_OK; }