Example #1
1
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();
    }
}
Example #2
1
void CNetRadioDlg::OnBnClickedTest()
{
	CString strValue;
	IHTMLDocument2* pDoc = (IHTMLDocument2*)m_Browser.GetHtmlDocument();
	HRESULT hr = S_FALSE;
	IHTMLElementCollection* pAllElem = NULL;
	IHTMLElementCollection* pAllScript = NULL;
	IHTMLElement* pElem = NULL;

	hr = pDoc->get_scripts(&pAllScript);
	if(SUCCEEDED(hr) && pAllScript != NULL)
	{
		IDispatchPtr pElemDisp = NULL;
		_variant_t varID(1);
		_variant_t varIdx(0);
		hr = pAllScript->item(varID, varIdx, &pElemDisp);
		if(SUCCEEDED(hr) && pElemDisp != NULL)
		{
			hr = pElemDisp->QueryInterface(IID_IHTMLElement,(void**)&pElem);
			if(SUCCEEDED(hr) && pElem != NULL)
			{
				BSTR bstrTagName;
				hr = pElem->get_outerHTML(&bstrTagName);
			
				hr = pElem->get_outerHTML(&bstrTagName);
				if(SUCCEEDED(hr))
				{
					CString strTagName(bstrTagName);
					SysFreeString(bstrTagName);
					MessageBox(strTagName);
				}
			}
		}
	}

	hr = pDoc->get_all(&pAllElem);

	if(SUCCEEDED(hr) && pAllElem != NULL)
	{
		IDispatchPtr pElemDisp = NULL;
		_variant_t varID(_T("body"));
		_variant_t varIdx(0);
		hr = pAllElem->item(varID, varIdx, &pElemDisp);
		if(SUCCEEDED(hr) && pElemDisp != NULL)
		{
			MessageBox(_T("OK"));
		}
	}

}
Example #3
0
void ExplorerElement::getChildren(std::vector<AbstractWebElement*> &children)
{
	children.clear();
	IHTMLElement *e;
	long size;
	IDispatch *childrenDisp;
	IHTMLElementCollection *col;
	HRESULT hr = m_pElement->QueryInterface(IID_IHTMLElement, reinterpret_cast<void**>(&e));
	if (!FAILED(hr) && e != NULL)
	{
		hr = e->get_children(&childrenDisp);
	}
	if (!FAILED(hr))
		hr = childrenDisp-> QueryInterface(IID_IHTMLElementCollection, reinterpret_cast<void**>(&col));
	if (!FAILED(hr) && col != NULL)
		hr=col->get_length(&size);
	if (!FAILED(hr))
	{
		IDispatch *el2;
		VARIANT v1, v2;
		v1.vt = VT_NULL;
		for (int i = 0 ; !FAILED(hr) && i < size; i++)
		{
			v2.vt = VT_I4;
			v2.lVal = i;
			hr = col->item(v2, v2, &el2);
			if (!FAILED(hr))
			{
				children.push_back(new ExplorerElement(el2, m_pApp));
				el2->Release();
			}
		}
	}
	col->Release();
}
Example #4
0
/**
 * Returns the destination url (href) of the given anchor element (or parent anchor element)
 **/
BSTR IEView::getHrefFromAnchor(IHTMLElement *element) {
    if (element != NULL) {
    	IHTMLAnchorElement * pAnchor;
        if (SUCCEEDED(element->QueryInterface(IID_IHTMLAnchorElement, (void**)&pAnchor)) && (pAnchor!=NULL)) {
			VARIANT	variant;
            BSTR url;
            if (SUCCEEDED(element->getAttribute(L"href", 2, &variant) && variant.vt == VT_BSTR)) {
				url = Utils::dupString(variant.bstrVal);
				SysFreeString(variant.bstrVal);
			}
            //pAnchor->get_href( &url );
//            if (url!=NULL) {
  //          	url2 = Utils::dupString(url);
  //          	SysFreeString(url);
    //        	url = url2;
      //     	}
            pAnchor->Release();
            return url;
        } else {
            IHTMLElement * parent;
            if (SUCCEEDED(element->get_parentElement(&parent)) && (parent!=NULL)) {
            	BSTR url = getHrefFromAnchor(parent);
            	parent->Release();
            	return url;
           	}
        }
    }
    return NULL;
}
Example #5
0
bool IEView::mouseClick(POINT pt) {
    bool result = false;
    if (GetFocus() != hwnd) {
		getFocus = true;
	}
	IHTMLDocument2 *document = getDocument();
	if (document != NULL) {
        IHTMLElement *element;
  		if (SUCCEEDED(document->elementFromPoint( pt.x, pt.y, &element ))&& element!=NULL) {
//		IHTMLAnchorElement * pAnchor;
//			if (SUCCEEDED(element->QueryInterface(IID_IHTMLAnchorElement, (void**)&pAnchor)) && (pAnchor!=NULL)) {
//				element->click();
//				result = true;
//				pAnchor->Release();
//			}
  			BSTR url = getHrefFromAnchor(element);
  			if (url != NULL) {
				if ((GetKeyState(VK_SHIFT) & 0x8000) && !(GetKeyState(VK_CONTROL) & 0x8000)
				&& !(GetKeyState(VK_MENU) & 0x8000)) {
					SendMessage(GetParent(hwnd), WM_COMMAND, IDCANCEL, 0);
				}
  			    int i = wcslen(url);
  			    char *tTemp = new char[i+1];
  			    WideCharToMultiByte(CP_ACP, 0, url, -1, tTemp, i+1, NULL, NULL);
		    	CallService(MS_UTILS_OPENURL, (WPARAM) 1, (LPARAM) tTemp);
                delete tTemp;
                delete url;
                result = true;
  			}
  			element->Release();
  		}
	    document->Release();
	}
	return result;
}
Example #6
0
BSTR IEView::getHrefFromAnchor(IHTMLElement *element) {
    if (element != NULL) {
    	IHTMLAnchorElement * pAnchor;
        if (SUCCEEDED(element->QueryInterface(IID_IHTMLAnchorElement, (void**)&pAnchor)) && (pAnchor!=NULL)) {
            BSTR url;
            BSTR url2;
            pAnchor->get_href( &url );
            if (url!=NULL) {
            	url2 = wcsdup(url);
            	SysFreeString(url);
            	url = url2;
           	}
            pAnchor->Release();
            return url;
        } else {
            IHTMLElement * parent;
            if (SUCCEEDED(element->get_parentElement(&parent)) && (parent!=NULL)) {
            	BSTR url = getHrefFromAnchor(parent);
            	parent->Release();
            	return url;
           	}
        }
    }
    return NULL;
}
void CIncrementSystemBFDlg::ProcessElementCollection(IHTMLElementCollection* pElemColl, CString id)
{	
	IDispatch* pElemDisp = NULL;
	IHTMLElement* pElem = NULL;
	VARIANT vID;
	VARIANT vIdx;

	VariantInit(&vID);
	vID.vt=VT_BSTR;
	vID.bstrVal=_bstr_t(id);

	VariantInit(&vIdx);
			  
	vIdx.vt=VT_I4;
	vIdx.lVal=0;

	HRESULT hr = pElemColl->item( vID, vIdx, &pElemDisp );
	if ( SUCCEEDED(hr) && pElemDisp != 0x0)
	{
		hr = pElemDisp->QueryInterface( IID_IHTMLElement, (void**)&pElem );
		if ( SUCCEEDED(hr) )
		{
			// Obtained element with ID of "myID".
			BSTR bsHtml;
			pElem->get_outerHTML(&bsHtml);
			CLogFile::WriteLog(bsHtml);

			ConnectButton1( pElem );
			pElem->Release();	
		}
		pElemDisp->Release();
	}
	pElemColl->Release();
}
Example #8
0
//-------------------------------------------------------------------------------
// Name: HrGetBody
// Desc: Получит тело Dockumeta если он создан ...
//-------------------------------------------------------------------------------
HRESULT COfsDhtmlEditCtrl::HrGetBody(IHTMLBodyElement** ppBody)
{
	HRESULT hr = E_FAIL;
	IHTMLDocument2* pDoc = NULL;

	*ppBody = NULL;

	if (SUCCEEDED(HrGetDoc(&pDoc)))
	{
		IHTMLElement* pElement = NULL;

		hr = pDoc->get_body(&pElement);

		if (SUCCEEDED(hr))
		{
			IHTMLBodyElement* pBody = NULL;
			hr = pElement->QueryInterface(IID_IHTMLBodyElement, (void **) &pBody);

			if (SUCCEEDED(hr))
			{
				*ppBody = pBody;

				// don't release body - we are returning it
			}
			
			pElement->Release();
		}

		pDoc->Release();
	}

	return hr;
}
Example #9
0
bool IEView::mouseClick(POINT pt) {
    bool result = false;
    if (GetFocus() != hwnd) {
		getFocus = true;
	}
	IHTMLDocument2 *document = getDocument();
	if (document != NULL) {
        IHTMLElement *element;
  		if (SUCCEEDED(document->elementFromPoint( pt.x, pt.y, &element ))&& element!=NULL) {
  			BSTR url = getHrefFromAnchor(element);
  			if (url != NULL) {
  			    int i = wcslen(url);
  			    char *tTemp = new char[i+1];
  			    WideCharToMultiByte(CP_ACP, 0, url, -1, tTemp, i+1, NULL, NULL);
		    	CallService(MS_UTILS_OPENURL, (WPARAM) 1, (LPARAM) tTemp);
                delete tTemp;
                free (url);
                result = true;
  			}
  			element->Release();
  		}
	    document->Release();
	}
	return result;
}
Example #10
0
void CHtmlViewNotice::HideScrollBar()
{
	IDispatch *pDisp = GetHtmlDocument();
	if( pDisp != NULL )
	{
		IHTMLDocument2* pHTMLDocument2;

		HRESULT hr;
		hr = pDisp->QueryInterface(IID_IHTMLDocument2, (void**)&pHTMLDocument2);

		if( hr == S_OK )
		{
			IHTMLElement *pIElement;

			hr = pHTMLDocument2->get_body(&pIElement);

			if( pIElement )
			{
				IHTMLBodyElement *pIBodyElement;

				hr = pIElement->QueryInterface(IID_IHTMLBodyElement,(void**)&pIBodyElement);

				pIBodyElement->put_scroll(L"no");
				pIBodyElement->Release();
			}
		}

		pHTMLDocument2->Release();
		pDisp->Release();
	}
}
Example #11
0
BOOL SimpleBrowser::GetElementText(LPCTSTR elementName, LPTSTR bf, UINT bfLen)
{
	IHTMLDocument3* pDocument = GetDocument3();
	if (pDocument == NULL)
		return FALSE;
	BOOL bRet = FALSE;
	IHTMLElement* pElement = NULL;
	CComBSTR elemName = elementName;
	if (pDocument->getElementById(elemName, &pElement) == S_OK && pElement != NULL)
	{
		CComBSTR innerText;
		if (pElement->get_innerText(&innerText) == S_OK)
		{
			if (innerText.Length() > 0)
			{
				_tcsncpy(bf, innerText, bfLen);
				bf[bfLen - 1] = 0;
			}
			else
				bf[0] = 0;
			bRet = TRUE;
		}
		pElement->Release();
	}
	pDocument->Release();
	return bRet;

}
Example #12
0
bool IEView::mouseClick(POINT pt) {
	bool result = false;
	if (GetFocus() != hwnd) {
		getFocus = true;
	}
	IHTMLDocument2 *document = getDocument();
	if (document != NULL) {
		IHTMLElement *element;
		if (SUCCEEDED(document->elementFromPoint( pt.x, pt.y, &element ))&& element!=NULL) {
//		IHTMLAnchorElement * pAnchor;
//			if (SUCCEEDED(element->QueryInterface(IID_IHTMLAnchorElement, (void**)&pAnchor)) && (pAnchor!=NULL)) {
//				element->click();
//				result = true;
//				pAnchor->Release();
//			}
			BSTR url = getHrefFromAnchor(element);
			if (url != NULL) {
				if ((GetKeyState(VK_SHIFT) & 0x8000) && !(GetKeyState(VK_CONTROL) & 0x8000)
				&& !(GetKeyState(VK_MENU) & 0x8000)) {
					SendMessage(GetParent(hwnd), WM_COMMAND, IDCANCEL, 0);
				}
				CallService(MS_UTILS_OPENURL, OUF_NEWWINDOW|OUF_TCHAR, (LPARAM) url);
				mir_free(url);
				result = true;
			}
			element->Release();
		}
		document->Release();
	}
	return result;
}
Example #13
0
//-----------------------------------------------------------------------------
// Name: AddHtmlContentToElement
// Object: 
// Parameters :
//     in  : 
//     out : 
//     return : 
//-----------------------------------------------------------------------------
BOOL CHtmlViewer::AddHtmlContentToElement(TCHAR* Id,TCHAR* Content)
{
    if (this->pIWebBrowser==NULL)
        return FALSE;

    if (!this->IsPageCompleted())
        return FALSE;

    HRESULT hr;
    BOOL bRet;
    IDispatch* pHtmlDocDispatch = NULL;
    IHTMLDocument3* pHtmlDoc = NULL;
    IHTMLElement* pElem = NULL;
    BSTR bstrElementId;

#if ((!defined(UNICODE))&& (!defined(_UNICODE)))
    WCHAR* psz;
#endif

    // get IDispatch document interface
    hr = pIWebBrowser->get_Document(&pHtmlDocDispatch);
    if (FAILED (hr) || (pHtmlDocDispatch == NULL))
        return FALSE;

    // get IHTMLDocument3 document interface
    hr = pHtmlDocDispatch->QueryInterface(IID_IHTMLDocument3,(void**)&pHtmlDoc);
    if (FAILED (hr) || (pHtmlDoc == NULL))
    {
        pHtmlDocDispatch->Release();
        return FALSE;
    }

    // get pointer to element from it's Id
#if (defined(UNICODE)||defined(_UNICODE))
    bstrElementId=SysAllocString(Id);
#else
    CAnsiUnicodeConvert::AnsiToUnicode(Id,&psz);
    bstrElementId=SysAllocString(psz);
    free(psz);    
#endif

    hr = pHtmlDoc->getElementById(bstrElementId,&pElem);
    SysFreeString(bstrElementId);
    if (FAILED (hr) || (pElem == NULL))
    {
        pHtmlDoc->Release();
        pHtmlDocDispatch->Release();
        return FALSE;
    }

    bRet=this->AddHtmlContentToElement(pElem,Content);

    pElem->Release();
    pHtmlDoc->Release();
    pHtmlDocDispatch->Release();

    return bRet;
}
Example #14
0
void ExplorerElement::click()
{
	IHTMLElement *e;
	HRESULT hr = m_pElement->QueryInterface(IID_IHTMLElement, reinterpret_cast<void**>(&e));
	if (!FAILED(hr) && e != NULL)
	{
		hr = e->click();
		e->Release();
	}
}
Example #15
0
void ExplorerElement::setTextContent(const char* text) {
	IHTMLElement *e;
	HRESULT hr = m_pElement->QueryInterface(IID_IHTMLElement, reinterpret_cast<void**>(&e));
	if (!FAILED(hr) && e != NULL)
	{
		BSTR bstrValue = Utils::str2bstr(text);
		hr = e->put_innerText(bstrValue);
		SysFreeString(bstrValue);
		e->Release();
	}
}
void CIncrementSystemBFDlg::OnDocumentCompleteExplorer1(LPDISPATCH pDisp, VARIANT FAR* URL) 
{
	DocumentCompleteExplorerSelectItem(pDisp, URL);
	// TODO: Add your control notification handler code here
	IDispatch * pDocDisp = NULL;
   
	// get the DOM
	IHTMLDocument2  *pDoc=NULL;
	pDocDisp = m_MyIE.GetDocument(); 
   
	if (pDocDisp != NULL) 
	{
      // Obtained the document object by specifying the IHTMLDocument2 Interface.
		HRESULT hr= pDocDisp->QueryInterface( IID_IHTMLDocument2, (void**)&pDoc );
		
		IHTMLElement* pBody = NULL;
		BSTR bstrBody;
		pDoc->get_body(&pBody);

		pBody->get_innerHTML(&bstrBody);

		if ( SUCCEEDED(hr) )
		{
			// Obtained the IHTMLDocument2 interface for the document object
			IHTMLElementCollection* pElemColl = NULL;
			hr = pDoc->get_all( &pElemColl );
			if ( SUCCEEDED(hr) )//ec
			{
				CComDispatchDriver spScript; 
				pDoc->get_Script(&spScript);  
				CComVariant var(static_cast<IDispatch*>(new CMyEventSink));  
				//spScript.Invoke1(L"SaveCppObject", &var); 
				// Obtained element collection.
				/*
#define LOGON_HTML_ID _T("Logon")
#define HTTP1_HTML_ID _T("Http1")
#define AUTH_HTML_ID _T("Authentication")
#define QUERYPT_HTML_ID _T("QueryPhoneType")
#define QUERYPOP_HTML_ID _T("QueryPopup")
#define QUERYPHONE_HTML_ID _T("QueryPhone")
#define HB_HTML_ID _T("Heartbeat")
#define RESETPWD_HTML_ID _T("ResetPassword")
#define LOGOFF_HTML_ID _T("Logoff")
				*/
				// buttonChangePassword   querySerialNumber
				
				ProcessElementCollection( pElemColl, "querySerialNumber");
			}
		}
		//ProcessDocument( pDocDisp );
	}
	pDocDisp->Release();
}
Example #17
0
void ExplorerElement::removeAttribute(const char* attribute) {
	IHTMLElement *e;
	HRESULT hr = m_pElement->QueryInterface(IID_IHTMLElement, reinterpret_cast<void**>(&e));
	if (!FAILED(hr) && e != NULL)
	{
		BSTR bstrValue = Utils::str2bstr(attribute);
		VARIANT_BOOL v;
		hr = e->removeAttribute(bstrValue, 0, &v);
		SysFreeString(bstrValue);
		e->Release();
	}
}
Example #18
0
void SetControlBoolAttribute(IHTMLDocument2 *pDoc, CString szId, CString szAttributeName, BOOL bValue)
{
    HRESULT hr = S_OK;
    IHTMLElement* pElem = NULL;
    hr = GetElementById(pDoc, szId, &pElem);
    if (hr == S_OK && pElem)
    {
        BSTR bstrAttributeName = szAttributeName.AllocSysString();
        VARIANT varAttr;
        varAttr.vt = VT_BOOL;
        varAttr.boolVal = bValue;
        pElem->setAttribute(bstrAttributeName, varAttr);
        ::SysFreeString(bstrAttributeName);
    }
}
GetHtmlElementAttributeResult GetHtmlElementAttribute(IHTMLElement& htmlElement,
  const ATL::CComBSTR& attributeName)
{
  GetHtmlElementAttributeResult retValue;
  ATL::CComVariant vAttr;
  ATL::CComPtr<IHTMLElement4> htmlElement4;
  if (FAILED(htmlElement.QueryInterface(&htmlElement4)) || !htmlElement4)
  {
    return retValue;
  }
  ATL::CComPtr<IHTMLDOMAttribute> attributeNode;
  if (FAILED(htmlElement4->getAttributeNode(attributeName, &attributeNode)) || !attributeNode)
  {
    return retValue;
  }
  // we set that attribute found but it's not necessary that we can retrieve its value
  retValue.isAttributeFound = true;
  if (FAILED(attributeNode->get_nodeValue(&vAttr)))
  {
    return retValue;
  }
  if (vAttr.vt == VT_BSTR && vAttr.bstrVal)
  {
    retValue.attributeValue = vAttr.bstrVal;
  }
  else if (vAttr.vt == VT_I4)
  {
    retValue.attributeValue = std::to_wstring(vAttr.iVal);
  }
  return retValue;
}
Example #20
0
void ExplorerElement::getTagName(std::string & value)
{
	IHTMLElement *e;
	value.clear ();
	HRESULT hr = m_pElement->QueryInterface(IID_IHTMLElement, reinterpret_cast<void**>(&e));
	if (!FAILED(hr) && e != NULL)
	{
		BSTR bstrTag;
		hr = e->get_tagName(&bstrTag);
		if (!FAILED(hr) && bstrTag != NULL) {
			Utils::bstr2str(value, bstrTag);
			SysFreeString(bstrTag);
		}
		e->Release();
	}
}
Example #21
0
AbstractWebElement *ExplorerElement::getOffsetParent()
{
	IHTMLElement *e;
	HRESULT hr = m_pElement->QueryInterface(IID_IHTMLElement, reinterpret_cast<void**>(&e));
	ExplorerElement *parent = NULL;
	if (!FAILED(hr)  && e != NULL)
	{
		IHTMLElement *nativeParent;
		hr = e->get_offsetParent(&nativeParent);
		if (nativeParent != NULL) {
			parent = new ExplorerElement(nativeParent, m_pApp);
			nativeParent->Release();
		}
		e->Release();
	}
	return parent;
}
Example #22
0
//-----------------------------------------------------------------------------
// Name: AddHtmlContentToBody
// Object: 
// Parameters :
//     in  : 
//     out : 
//     return : 
//-----------------------------------------------------------------------------
BOOL CHtmlViewer::AddHtmlContentToBody(TCHAR* Content)
{
    HRESULT hr;
    BOOL bRet;
    IDispatch* pHtmlDocDispatch = NULL;
    IHTMLDocument2* pHtmlDoc = NULL;
    IHTMLElement* pElem = NULL;

    if (this->pIWebBrowser==NULL)
        return FALSE;

    if (!this->IsPageCompleted())
        return FALSE;

    // get IDispatch document interface
    hr = pIWebBrowser->get_Document(&pHtmlDocDispatch);
    if (FAILED (hr) || (pHtmlDocDispatch == NULL))
        return FALSE;

    // get IHTMLDocument2 document interface
    hr = pHtmlDocDispatch->QueryInterface(IID_IHTMLDocument2,(void**)&pHtmlDoc);
    if (FAILED (hr) || (pHtmlDoc == NULL))
    {
        pHtmlDocDispatch->Release();
        return FALSE;
    }

    // get body
    hr = pHtmlDoc->get_body(&pElem);
    if (FAILED (hr) || (pElem == NULL))
    {
        pHtmlDoc->Release();
        pHtmlDocDispatch->Release();
        return FALSE;
    }

    bRet=this->AddHtmlContentToElement(pElem,Content);

    pElem->Release();
    pHtmlDoc->Release();
    pHtmlDocDispatch->Release();

    return bRet;
}
Example #23
0
void CTryData4Dlg::DisableConfigDefault()
{
	char i;
	IHTMLElement *newElement;
	for(i='1';i<='9';i++)
	{
		VARIANT varEnable;
		varEnable.vt = VT_BOOL;
		varEnable.boolVal = (m_sConfSel.Compare(DEFAULT_NAME) == 0);;

		if(S_OK == this->GetElement(CString("alphalt")+i,&newElement))
			newElement->setAttribute(L"disabled",varEnable);
		if(S_OK == this->GetElement(CString("betalt")+i,&newElement))
			newElement->setAttribute(L"disabled",varEnable);
		if(S_OK == this->GetElement(CString("rstdlt")+i,&newElement))
			newElement->setAttribute(L"disabled",varEnable);

	}
}
Example #24
0
void CShellDlg::DocumentCompleteExplorer2(LPDISPATCH pDisp3, VARIANT* URL)
{
    HRESULT hr;
//	IDispatch *pDisp2 = m_webHead .get_Document ();

    IHTMLDocument2 *pDocument = NULL;
    IHTMLElement*   pEl;
    IHTMLBodyElement   *   pBodyEl;
//	hr = pDisp2->QueryInterface(IID_IHTMLDocument2, (void**)&pDocument);
    if(SUCCEEDED(pDocument->get_body(&pEl)))
    {
        if(SUCCEEDED(pEl->QueryInterface(IID_IHTMLBodyElement,   (void**)&pBodyEl)))
        {
            pBodyEl->put_scroll(L"no");//去滚动条
        }
        IHTMLStyle   *phtmlStyle;
        pEl->get_style(&phtmlStyle);

    }
}
Example #25
0
CString GetControlStringAttribute(IHTMLDocument2 *pDoc, CString szId, CString szAttributeName)
{
    HRESULT hr = S_OK;
    IHTMLElement* pElem = NULL;
    hr = GetElementById(pDoc, szId, &pElem);
    if (hr == S_OK && pElem)
    {
        VARIANT varAttr;
        varAttr.vt = VT_BSTR;
        BSTR bstrAttributeName = szAttributeName.AllocSysString();
        hr = pElem->getAttribute(bstrAttributeName, 0, &varAttr);
        ::SysFreeString(bstrAttributeName);

        if (hr == S_OK && varAttr.vt == VT_BSTR)
        {
            return CString(varAttr.bstrVal);
        }
    }

    return "";
}
Example #26
0
BOOL GetControlBoolAttribute(IHTMLDocument2 *pDoc, CString szId, CString szAttributeName)
{
    HRESULT hr = S_OK;
    IHTMLElement* pElem = NULL;
    hr = GetElementById(pDoc, szId, &pElem);
    if (hr == S_OK && pElem)
    {
        VARIANT varAttr;
        varAttr.vt = VT_BOOL;
        BSTR bstrAttributeName = szAttributeName.AllocSysString();
        hr = pElem->getAttribute(bstrAttributeName, 0, &varAttr);
        ::SysFreeString(bstrAttributeName);        
        
        if (hr == S_OK && varAttr.vt == VT_BOOL)
        {
            return varAttr.boolVal;
        }
    }

    return FALSE;
}
Example #27
0
void DoClick(LPCTSTR windowName, LPCTSTR elementId, LPCTSTR elementName)
{
	MessageBox(NULL, "Started", "Info", MB_OK);
	CoInitialize( NULL );
	
	IHTMLDocument2* pDoc2 = NULL;
	pDoc2 = GetDoc2(windowName);

	if(pDoc2 != NULL)
	{
		IHTMLElement* pElem = FindElement(pDoc2, elementId, elementName);
		if(pElem != NULL)
		{
			pElem->click();
			pElem->Release();
		}

		pDoc2->Release();
	}

	CoUninitialize();
}
Example #28
0
void CHtmlViewer::OnDocumentCompleted()
{
    // disconnect / remove old documents events
    if (this->pDocumentElementEvents)
        delete this->pDocumentElementEvents;

    // attach new documents events
    HRESULT hr;
    IDispatch* pHtmlDocDispatch = NULL;
    IHTMLDocument3* pHtmlDoc = NULL;
    // Retrieve the document object.

    hr = pIWebBrowser->get_Document(&pHtmlDocDispatch);
    if (SUCCEEDED (hr) && (pHtmlDocDispatch != NULL))
    {
        hr = pHtmlDocDispatch->QueryInterface(IID_IHTMLDocument3,(void**)&pHtmlDoc);
        if (SUCCEEDED (hr) && (pHtmlDoc != NULL))
        {

            IHTMLElement* pElem = NULL;
            pHtmlDoc->get_documentElement(&pElem);

            this->pDocumentElementEvents=new CElementEvents(pElem);
            this->pDocumentElementEvents->ConnectEvents();

            this->pDocumentElementEvents->SetElementEventsCallBack(this->ElementEventsCallBack,this->ElementEventsCallBackUserParam);
            this->pDocumentElementEvents->SetElementEventsCallBackEx(this->ElementEventsCallBackEx,this->ElementEventsCallBackExUserParam);

            this->pDocumentElementEvents->EnableSelection(this->bEnableSelection);
            this->pDocumentElementEvents->EnableContextMenu(this->bEnableContextMenu);

            pElem->Release();
            pHtmlDoc->Release();
        }

        pHtmlDocDispatch->Release();
    }
}
Example #29
0
HRESULT TestDocumentText(IHTMLDocument3 *pHtmlDoc, BSTR &message)
{
	IHTMLDocument2 *pDoc = NULL;
	IHTMLElement *pElem = NULL;
	BSTR bstrId = SysAllocString(L"test");

	HRESULT hr = pHtmlDoc->QueryInterface(IID_PPV_ARGS(&pDoc));
	if (SUCCEEDED(hr) && pDoc) {
		hr = pDoc->get_body(&pElem);
		if (SUCCEEDED(hr) && pElem) {
			BSTR bstrText = NULL;
			pElem->get_innerText(&bstrText);
			message = SysAllocString(bstrText);
			SysFreeString(bstrText);
			pElem->Release();
		}

		pDoc->Release();
	}

	SysFreeString(bstrId);
	return hr;
}
Example #30
0
void CMFCApplication2View::OnDocumentComplete(LPCTSTR lpszURL)
{
	CHtmlView::OnDocumentComplete(lpszURL);
	if (lpszURL != nullptr) {
		CString strURL(lpszURL);
		static int i = 0;
		if (strURL.Find(_T("127.0.0.1.com/?code=")) > 0 && i == 0)
		{
			CString strCode = strURL.Mid(strURL.Find(_T("127.0.0.1.com/?code="))+20);
			CString strNewURL(_T("https://api.ciscospark.com/v1/access_token"));
			CString strPostData(_T("grant_type=authorization_code&client_id=Ce07a320a3e5fd132ac55854ef107e48988fb573b0478c4126df9f01d941a3ec3&client_secret=ec699f8e1f970a7b4e76b06ca226e1d5e3a5c40ee509cacbda2f6d1da7662b67&redirect_uri=http%3A%2F%2F127.0.0.1.com&code="));
			strPostData.Append(strCode);
			Navigate2(strNewURL, NULL, NULL, NULL, (LPVOID)(LPCTSTR)strPostData, (DWORD)strPostData.GetLength());
			i++;
		}

		
		if (i == 1) {
			LPDISPATCH   lpDispatch;
			lpDispatch = GetHtmlDocument();
			ASSERT(lpDispatch);
			CComQIPtr <IHTMLDocument2, &IID_IHTMLDocument2>   pDoc2;
			HRESULT   hr;
			hr = lpDispatch->QueryInterface(IID_IHTMLDocument2, (void**)&pDoc2);
			if (SUCCEEDED(hr))
			{
				IHTMLElement   *pBodyElement;
				pDoc2->get_body(&pBodyElement);
				BSTR   body;
				pBodyElement->get_innerHTML(&body);
				char * strBody = ::_com_util::ConvertBSTRToString(body);
				pDoc2.Release();
			}
			lpDispatch->Release();
		}
	}
}