void IEView::scrollToBottom() { /* IHTMLDocument2 *document = getDocument(); if (document != NULL) { wchar_t *p = NULL; if (SUCCEEDED(document->get_readyState(&p))) { int licznik = 0; do { if (FAILED(document->get_readyState(&p))) { break; } licznik++; if (licznik == 1) break; Sleep(10); } while (!wcscmp(p, L"loading")); } IHTMLWindow2* pWindow = NULL; if (SUCCEEDED(document->get_parentWindow( &pWindow )) && pWindow != NULL) { pWindow->scrollBy( 0, 0x01FFFFFF ); } document->Release(); }*/ IHTMLDocument2 *document = getDocument(); if (document != NULL) { IHTMLElementCollection *collection; IHTMLElement *element; IDispatch *dispatch; if (SUCCEEDED(document->get_all(&collection)) && (collection != NULL)) { long len; if (SUCCEEDED(collection->get_length(&len))) { VARIANT variant; variant.vt = VT_I4; variant.lVal = len-1; if (SUCCEEDED(collection->item(variant, variant, &dispatch)) && (dispatch != NULL)) { if (SUCCEEDED(dispatch->QueryInterface(IID_IHTMLElement,(void**)&element)) && (element != NULL)) { variant.vt = VT_BOOL; variant.boolVal = VARIANT_FALSE; if (SUCCEEDED(element->scrollIntoView(variant))) { } element->Release(); } dispatch->Release(); } } collection->Release(); } IHTMLWindow2* pWindow = NULL; if (SUCCEEDED(document->get_parentWindow( &pWindow )) && (pWindow != NULL)) { pWindow->scrollBy( -0x01FFFFFF, 0x01FFFFFF ); pWindow->Release(); } document->Release(); } }
void IEView::scrollToBottomSoft() { IHTMLDocument2 *document = getDocument(); if (document != NULL) { IHTMLWindow2* pWindow = NULL; if (SUCCEEDED(document->get_parentWindow( &pWindow )) && (pWindow != NULL)) { pWindow->scrollBy( -0x01FFFFFF, 0x01FFFFFF ); pWindow->Release(); } document->Release(); } }
STDMETHODIMP CPdnWnd::FireEvent(BSTR handler, VARIANT* parameters, DWORD nParams) { if(!m_pBrowser) return S_FALSE; IHTMLDocument2* pHTDoc; HRESULT hr; hr = m_pBrowser->get_Document((IDispatch**) &pHTDoc); if(SUCCEEDED(hr) && pHTDoc) { IHTMLWindow2* pHTWnd = NULL; hr = pHTDoc->get_parentWindow(&pHTWnd); if(SUCCEEDED(hr)) { UINT errArg; DISPID dispid; hr = pHTWnd->GetIDsOfNames(IID_NULL, &handler, 1, LOCALE_SYSTEM_DEFAULT, &dispid); if(SUCCEEDED(hr)) { DISPPARAMS dParams = { parameters, 0, nParams, 0 }; hr = pHTWnd->Invoke(dispid, IID_NULL, LOCALE_SYSTEM_DEFAULT, DISPATCH_METHOD, &dParams, 0, 0, &errArg); if(SUCCEEDED(hr)) { pHTWnd->Release(); pHTDoc->Release(); return S_OK; } } pHTWnd->Release(); } pHTDoc->Release(); } return hr; }
BOOL SimpleBrowser::ExecuteJavascript(LPCTSTR script) { IHTMLDocument2* pDocument = GetDocument(); if (pDocument == NULL) return FALSE; BOOL bRet = FALSE; IHTMLWindow2* pHTMLWindow = NULL; if (pDocument->get_parentWindow(&pHTMLWindow) == S_OK)// execCommand(_T("testFunction()"), TRUE, value, &ret)) { VARIANT vEmpty = {0}; CComBSTR bstrFunction = script; CComBSTR bstrLanguage = L"javascript"; HRESULT hr = pHTMLWindow->execScript(bstrFunction, bstrLanguage, &vEmpty); bRet = (hr == S_OK); pHTMLWindow->Release(); } pDocument->Release(); return bRet; }
std::string ExplorerElement::getComputedStyle(const char* style) { std::string value; // pDoc = element.document IHTMLDocument2 *pDoc = m_pApp->getHTMLDocument2(); if (pDoc != NULL) { IHTMLWindow2 *w = NULL; // w = pDoc.parentWindow HRESULT hr = pDoc->get_parentWindow(&w); if (! FAILED (hr)) { IHTMLWindow7 *w7 = NULL; w->QueryInterface(local_IID_IHTMLWindow7, reinterpret_cast<void**>(&w7)); if (FAILED(hr) || w7 == NULL) { // MZNSendDebugMessageA("Cannot get w7"); } else { IHTMLDOMNode *node; HRESULT hr = m_pElement->QueryInterface(IID_IHTMLDOMNode, reinterpret_cast<void**>(&node)); if (FAILED(hr) || node == NULL) { // MZNSendDebugMessageA("Cannot cast to htmldomnode"); } else { IHTMLCSSStyleDeclaration *pComputedStyle; hr = w7->getComputedStyle(node, NULL, &pComputedStyle); if ( FAILED(hr)) { // MZNSendDebugMessage("Cannot get computedStyle"); } else { BSTR bstr = Utils::str2bstr(style); BSTR bstr2 = NULL; hr = pComputedStyle->getPropertyValue(bstr, &bstr2); if (FAILED(hr)) { // MZNSendDebugMessage("Cannot get property on computedStyle %s", style); } else { Utils::bstr2str(value, bstr2); if (bstr2 != NULL) SysFreeString(bstr2); } SysFreeString(bstr); pComputedStyle -> Release(); } node->Release(); } w7->Release(); } w->Release(); } } return value; }