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
0
static int MyShellDispatch_ShellDispatchProc(const shell_dispatch_handler_t handler, void *const data)
{
	int iSuccess = SHELL_DISPATCH_FAILED;

	IShellWindows *psw = NULL;
	HRESULT hr = CoCreateInstance(CLSID_ShellWindows, NULL, CLSCTX_LOCAL_SERVER, IID_PPV_ARGS(&psw));
	if(SUCCEEDED(hr))
	{
		HWND desktopHwnd = 0;
		IDispatch* pdisp = NULL;
		variant_t vEmpty;
		if(S_OK == psw->FindWindowSW(vEmpty, vEmpty, SWC_DESKTOP, (long*)&desktopHwnd, SWFO_NEEDDISPATCH, &pdisp))
		{
			if(VALID_HANDLE(desktopHwnd))
			{
				IShellBrowser *psb;
				hr = IUnknown_QueryService(pdisp, SID_STopLevelBrowser, IID_PPV_ARGS(&psb));
				if(SUCCEEDED(hr))
				{
					IShellView *psv = NULL;
					hr = psb->QueryActiveShellView(&psv);
					if(SUCCEEDED(hr))
					{
						IDispatch *pdispBackground = NULL;
						HRESULT hr = psv->GetItemObject(SVGIO_BACKGROUND, IID_PPV_ARGS(&pdispBackground));
						if(SUCCEEDED(hr))
						{
							MyShellDispatch_AllowSetForegroundWindow(desktopHwnd);
							IShellFolderViewDual *psfvd = NULL;
							HRESULT hr = pdispBackground->QueryInterface(IID_PPV_ARGS(&psfvd));
							if(SUCCEEDED(hr))
							{
								IDispatch *pdisp = NULL;
								hr = psfvd->get_Application(&pdisp);
								if(SUCCEEDED(hr))
								{
									IShellDispatch2 *pShellDispatch;
									hr = pdisp->QueryInterface(IID_PPV_ARGS(&pShellDispatch));
									if(SUCCEEDED(hr))
									{
										iSuccess = handler(pShellDispatch, data);
									}
									RELEASE_OBJ(pdisp);
								}
								RELEASE_OBJ(psfvd);
							}
							RELEASE_OBJ(pdispBackground);
						}
						RELEASE_OBJ(psv);
					}
					RELEASE_OBJ(psb);
				}
			}
			RELEASE_OBJ(pdisp);
		}
		RELEASE_OBJ(psw);
	}

	return iSuccess;
}
Example #3
0
static HRESULT GetShellDispatchFromView(
    __in IShellView *psv,
    __in REFIID riid,
    __out void **ppv
    )
{
    HRESULT hr = S_OK;
    IDispatch *pdispBackground = NULL;
    IShellFolderViewDual *psfvd = NULL;
    IDispatch *pdisp = NULL;

    // From a shell view object, gets its automation interface and from that get the shell
    // application object that implements IShellDispatch2 and related interfaces.
    hr = psv->GetItemObject(SVGIO_BACKGROUND, IID_PPV_ARGS(&pdispBackground));
    ExitOnFailure(hr, "Failed to get the automation interface for shell.");

    hr = pdispBackground->QueryInterface(IID_PPV_ARGS(&psfvd));
    ExitOnFailure(hr, "Failed to get shell folder view dual.");

    hr = psfvd->get_Application(&pdisp);
    ExitOnFailure(hr, "Failed to application object.");

    hr = pdisp->QueryInterface(riid, ppv);
    ExitOnFailure(hr, "Failed to get IShellDispatch2.");

LExit:
    ReleaseObject(pdisp);
    ReleaseObject(psfvd);
    ReleaseObject(pdispBackground);

    return hr;
}
HRESULT GetShellDispatchFromView(IShellView *psv, REFIID riid, void **ppv)
{
    *ppv = NULL;

    IDispatch *pdispBackground;
    HRESULT hr = psv->GetItemObject(SVGIO_BACKGROUND, IID_PPV_ARGS(&pdispBackground));
    if (SUCCEEDED(hr))
    {
        IShellFolderViewDual *psfvd;
        hr = pdispBackground->QueryInterface(IID_PPV_ARGS(&psfvd));
        if (SUCCEEDED(hr))
        {
            IDispatch *pdisp;
            hr = psfvd->get_Application(&pdisp);
            if (SUCCEEDED(hr))
            {
                hr = pdisp->QueryInterface(riid, ppv);
                pdisp->Release();
            }
            psfvd->Release();
        }
        pdispBackground->Release();
    }
    return hr;
}
Example #5
0
//taken from http://www.wischik.com/lu/programmer/webform.html
IHTMLElement* TextRenderBrain::GetElementFromId(string id_str, const GUID *iid)
{
	const char* id = NULL;
	IHTMLElement *ret=0; 
	IHTMLElementCollection* doc_all = NULL;
	IHTMLDocument2 *doc = NULL; 
	HRESULT hr;

	if (id_str.size() == 0) return 0;
	
	id = id_str.c_str();
	doc = GetDoc();

	if (doc==0) return 0;
	hr = doc->get_all(&doc_all);      // this is like doing document.all
  
	if (hr == S_OK)
	{ 
		IDispatch* disp = NULL;
		VARIANT vid;
		VARIANT v0; 
		unsigned int len;
		wchar_t* ws = NULL;

		VariantInit(&v0);
		len=strlen(id);
		vid.vt=VT_BSTR;
    
		ws = new wchar_t[len+1];
		MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED, id, -1, ws, len+1);
		vid.bstrVal=ws;

		hr = doc_all->item(vid,v0,&disp);       // this is like doing document.all["messages"]
		delete[] ws;

		//We may be leaking a small amount of memory here because this crashes:
		//SysFreeString(vid.bstrVal);
		
		if (hr == S_OK && disp != 0)
		{ 
			IHTMLElement* element = NULL;

			if (iid == 0) hr = disp->QueryInterface(IID_IHTMLElement,(void **)&element);
			else hr = disp->QueryInterface(*iid,(void**)&element);
      
			if (hr == S_OK) ret = element; // it's the caller's responsibility to release it
			disp->Release();
		}
		doc_all->Release();
	}
	doc->Release();
	return ret;
}
Example #6
0
void CIEBrowserEngine::RunMessageLoop(CMainWindow& mainWnd)
{
	MSG msg;
    while (GetMessage(&msg, NULL, 0, 0))
    {
		if (RHODESAPP().getExtManager().onWndMsg(msg) )
            continue;

		IDispatch* pDisp;
		SendMessage(m_hwndTabHTML, DTM_BROWSERDISPATCH, 0, (LPARAM) &pDisp); // New HTMLVIEW message
		if (pDisp != NULL) {
			//  If the Key is back we do not want to translate it causing the browser
			//  to navigate back.
			if ( ((msg.message != WM_KEYUP) && (msg.message != WM_KEYDOWN)) || (msg.wParam != VK_BACK) )
			{
				IOleInPlaceActiveObject* pInPlaceObject;
				pDisp->QueryInterface( IID_IOleInPlaceActiveObject, (void**)&pInPlaceObject );
				HRESULT handleKey = pInPlaceObject->TranslateAccelerator(&msg);	
			}
		}

        if (!mainWnd.TranslateAccelerator(&msg))
        {
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }

		if(msg.message == WM_PAINT)
			RHODESAPP().getExtManager().onHTMLWndMsg(msg);	
    }
}
Example #7
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();
	}
}
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 #9
0
HRESULT GetElementById(IHTMLDocument2 *pDoc, CString szId, IHTMLElement** pElem)
{
    *pElem = NULL;
    HRESULT hr = S_OK;

    BSTR bstrID = szId.AllocSysString();
    VARIANT varName, varIndex;
    varName.vt = VT_BSTR;
    varName.bstrVal = bstrID;
    varIndex.vt = VT_I4;
    varIndex.intVal = 0;        

    IHTMLElementCollection *pColl;
    hr = pDoc->get_all(&pColl);

    if (hr == S_OK && pColl)
    {
        IDispatch* pDisp;
        hr = pColl->item(varName, varIndex, &pDisp);
        if (hr == S_OK && pDisp)
        {
            hr = pDisp->QueryInterface(IID_IHTMLElement, (void**)pElem);
        }
    }
    
    ::SysFreeString(bstrID);

    return hr;
}
STDMETHODIMP CompositeOverlayImpl<B>::put_Overlays(LPSAFEARRAY newVal)
{
	ClearAndDestroy();
	long lb = 0;
	long ub = 0;
	if( !(newVal->fFeatures & FADF_DISPATCH) )
		return E_INVALIDARG;

	HRESULT hr = ::SafeArrayGetUBound(newVal, 1, &ub);
	hr = ::SafeArrayGetLBound(newVal, 1, &lb);

	IDispatch *pDisp;
	IOverlay *pOverlay;
	long indices[1];
	for (int i=lb; i<=ub; i++)
	{
		indices[0] = i;
		pDisp = 0;
		::SafeArrayGetElement(newVal, indices, &pDisp);
		if (pDisp)
		{
			if (SUCCEEDED(pDisp->QueryInterface(__uuidof(IOverlay), (void**)&pOverlay)))
			{
				AtlTrace("Added overlay to composite\n");
				Add(pOverlay);
				pOverlay->Release();
			}
			pDisp->Release();
		}
	}

	return S_OK;
}
Example #11
0
HRESULT LoadWebBrowserFromStream(IWebBrowser* pWebBrowser, IStream* pStream)
{
	HRESULT hr;
	IDispatch* pHtmlDoc = NULL;
	IPersistStreamInit* pPersistStreamInit = NULL;

	// Retrieve the document object.
	hr = pWebBrowser->get_Document( &pHtmlDoc );
	if ( SUCCEEDED(hr) )
	{
		// Query for IPersistStreamInit.
		hr = pHtmlDoc->QueryInterface( IID_IPersistStreamInit,  (void**)&pPersistStreamInit );
		if ( SUCCEEDED(hr) )
		{
			// Initialize the document.
			hr = pPersistStreamInit->InitNew();
			if ( SUCCEEDED(hr) )
			{
				// Load the contents of the stream.
				hr = pPersistStreamInit->Load( pStream );
			}
			pPersistStreamInit->Release();
		}
	}
	return S_OK;
}
Example #12
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 #13
0
void GetExplorerWindows(std::vector<PairHwndPath>& windows, BOOL needPaths) {
    IShellWindows *psw;
    if(SUCCEEDED(CoCreateInstance(CLSID_ShellWindows, NULL, CLSCTX_ALL, IID_IShellWindows, (void**)&psw))) {
        VARIANT v;
        V_VT(&v) = VT_I4;
        IDispatch* pdisp;
        for(V_I4(&v) = 0; psw->Item(v, &pdisp) == S_OK; V_I4(&v)++) {
            IWebBrowserApp *pwba;
            if(SUCCEEDED(pdisp->QueryInterface(IID_IWebBrowserApp, (void**)&pwba))) {
                PairHwndPath pair;
                if(SUCCEEDED(pwba->get_HWND((LONG_PTR*)&pair.hwnd))) {
                    IServiceProvider *psp;
                    if(needPaths && SUCCEEDED(pwba->QueryInterface(IID_IServiceProvider, (void**)&psp))) {
                        IShellBrowser *psb;
                        if(SUCCEEDED(psp->QueryService(SID_STopLevelBrowser, IID_IShellBrowser, (void**)&psb))) {
                            IShellView *psv;
                            if(SUCCEEDED(psb->QueryActiveShellView(&psv))) {
                                IFolderView *pfv;
                                if(SUCCEEDED(psv->QueryInterface(IID_IFolderView, (void**)&pfv))) {
                                    IPersistFolder2 *ppf2;
                                    if(SUCCEEDED(pfv->GetFolder(IID_IPersistFolder2, (void**)&ppf2))) {
                                        LPITEMIDLIST pidlFolder;
                                        if(SUCCEEDED(ppf2->GetCurFolder(&pidlFolder))) {
                                            if(!SHGetPathFromIDList(pidlFolder, pair.path)) {
                                                IShellFolder* psf;
                                                LPCITEMIDLIST pidlLast;
                                                if(SUCCEEDED(SHBindToParent(pidlFolder, IID_IShellFolder, (void**)&psf, &pidlLast))) {
                                                    STRRET strret;
                                                    if(SUCCEEDED(psf->GetDisplayNameOf(pidlLast, 0x8000, &strret))) {
                                                        StrRetToBuf(&strret, pidlLast, pair.path, MAX_PATH);
                                                    }
                                                    else {
                                                        pair.path[0] = 0;
                                                    }
                                                    psf->Release();
                                                }
                                            }
                                            CoTaskMemFree(pidlFolder);
                                        }
                                        ppf2->Release();
                                    }
                                    pfv->Release();
                                }
                                psv->Release();
                            }
                            psb->Release();
                        }
                        psp->Release();
                    }
                    windows.push_back(pair);
                }
                pwba->Release();
            }
            pdisp->Release();
        }
        psw->Release();
    }
}
Example #14
0
void IEView::clear() {
#ifdef GECKO
    pWebBrowser->Navigate(L"www.onet.pl", NULL, NULL, NULL, NULL);
    return;
#endif
    IHTMLDocument2 *document = getDocument();
    if (document == NULL) {
        pWebBrowser->Navigate(L"about:blank", NULL, NULL, NULL, NULL);
        HRESULT hr = S_OK;
        IHTMLDocument2 *document = NULL;
        while ((document == NULL) && (hr == S_OK)) {
            Sleep(0);
            IDispatch *dispatch = NULL;
            if (SUCCEEDED(pWebBrowser->get_Document(&dispatch)) && (dispatch != NULL)) {
                hr = dispatch->QueryInterface(IID_IHTMLDocument2, (void **)&document);
                dispatch->Release();
            }
        }
        if (document != NULL) {
            document->Release();
        }
    } else {
        document->close();
        VARIANT		open_name;
        VARIANT		open_features;
        VARIANT		open_replace;
        IDispatch	*open_window	= NULL;
        VariantInit(&open_name);
        open_name.vt      = VT_BSTR;
        open_name.bstrVal = SysAllocString(L"_self");
        VariantInit(&open_features);
        VariantInit(&open_replace);

        HRESULT hr = document->open(SysAllocString(L"text/html"),
                                    open_name,
                                    open_features,
                                    open_replace,
                                    &open_window);
        if (hr == S_OK) {
            //	pWebBrowser->Refresh();
        }
        if (open_window != NULL) {
            open_window->Release();
        }
        document->Release();
    }
    hDbEventFirst = NULL;
    if (builder!=NULL) {
        IEVIEWEVENT event;
        event.cbSize = sizeof(IEVIEWEVENT);
        event.hContact = hContact;
        event.dwFlags = dwLogFlags;
        event.codepage = iLogCodepage;
        builder->buildHead(this, &event);
    }
}
Example #15
0
HRESULT GetGC(IDirectorySearch **ppDS)
{
    HRESULT hr;
    IEnumVARIANT *pEnum = NULL;
    IADsContainer *pCont = NULL;
    VARIANT var;
    IDispatch *pDisp = NULL;
    ULONG lFetch;

    // Set IDirectorySearch pointer to NULL.
    *ppDS = NULL;

    // First, bind to the GC: namespace container object.
    hr = ADsOpenObject(TEXT("GC:"),
                       NULL,
                       NULL,
                       ADS_SECURE_AUTHENTICATION, // Use Secure Authentication.
                       IID_IADsContainer,
                       (void**)&pCont);
    if (FAILED(hr)) {
        _tprintf(TEXT("ADsOpenObject failed: 0x%x\n"), hr);
        goto cleanup;
    }

    // Get an enumeration interface for the GC container to enumerate the
    // contents. The actual GC is the only child of the GC container.
    hr = ADsBuildEnumerator(pCont, &pEnum);
    if (FAILED(hr)) {
        _tprintf(TEXT("ADsBuildEnumerator failed: 0x%x\n"), hr);
        goto cleanup;
    }

    // Now enumerate. There is only one child of the GC: object.
    hr = pEnum->Next(1, &var, &lFetch);
    if (FAILED(hr)) {
        _tprintf(TEXT("ADsEnumerateNext failed: 0x%x\n"), hr);
        goto cleanup;
    }

    // Get the IDirectorySearch pointer.
    if ((hr == S_OK) && (lFetch == 1))
    {
        pDisp = V_DISPATCH(&var);
        hr = pDisp->QueryInterface(IID_IDirectorySearch, (void**)ppDS);
    }

cleanup:

    if (pEnum)
        ADsFreeEnumerator(pEnum);
    if (pCont)
        pCont->Release();
    if (pDisp)
        (pDisp)->Release();
    return hr;
}
Example #16
0
IHTMLDocument2 *IEView::getDocument() {
	HRESULT hr = S_OK;
	IHTMLDocument2 *document = NULL;
	IDispatch *dispatch = NULL;
	if (SUCCEEDED(pWebBrowser->get_Document(&dispatch)) && (dispatch != NULL)) {
		hr = dispatch->QueryInterface(IID_IHTMLDocument2, (void **)&document);
		dispatch->Release();
	}
	return document;
}
static cgMSXML::IXMLElement* XML_GetNextElement(cgMSXML::IXMLElementCollection* pChildren, long* pNum)
{
    bool                    bOk;
    long                    typeId;
    VARIANT                 var1;
    VARIANT                 var2;
    IDispatch*              pDisp;
    long                    length;
    cgMSXML::IXMLElement*            pChild;
    
    
    pChildren->get_length(&length);
    var1.vt  = VT_I4;
    var2.vt  = VT_EMPTY;
    var1.lVal= *pNum;


nextChild:
    if(var1.lVal>= length)
        return NULL;


    if(FAILED(pChildren->item(var1, var2, &pDisp)) || !pDisp)
    {
        assert(!"pChildren->item failed");
        return NULL;
    }
    
    bOk = SUCCEEDED(pDisp->QueryInterface(cgMSXML::IID_IXMLElement, (void **)&pChild));
    pDisp->Release();
    
    if(!bOk)
    {
        assert(!"pDisp->QueryInterface failed");
        return NULL;
    }

    if(FAILED(pChild->get_type(&typeId)))
    {
        assert(!"pChild->get_type failed");
        pChild->Release();
        return NULL;
    }
    if(typeId!=cgMSXML::XMLELEMTYPE_ELEMENT || XML_GetFlag(pChild, XML_TAGS.ATTR_COMMENT))
    {
        pChild->Release();
        var1.lVal++;
        goto nextChild;
    }

    
    *pNum = ++var1.lVal;
    return pChild;
}
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 #19
0
HRESULT CpiGetCatalogCollection(
	ICatalogCollection* piColl,
	ICatalogObject* piObj,
	LPCWSTR pwzName,
	ICatalogCollection** ppiColl
	)
{
	HRESULT hr = S_OK;

	ICOMAdminCatalog* piCatalog = NULL;
	IDispatch* piDisp = NULL;

	BSTR bstrName = NULL;

	VARIANT vtKey;
	::VariantInit(&vtKey);

	// copy name string
	bstrName = ::SysAllocString(pwzName);
	ExitOnNull(bstrName, hr, E_OUTOFMEMORY, "Failed to allocate BSTR for collection name");

	// get catalog
	hr = CpiGetAdminCatalog(&piCatalog);
	ExitOnFailure(hr, "Failed to get COM+ admin catalog");

	// get key
	hr = piObj->get_Key(&vtKey);
	ExitOnFailure(hr, "Failed to get object key");

	// get collecton from catalog
	hr = piColl->GetCollection(bstrName, vtKey, &piDisp);
	ExitOnFailure(hr, "Failed to get collection");

	hr = piDisp->QueryInterface(IID_ICatalogCollection, (void**)ppiColl);
	ExitOnFailure(hr, "Failed to get IID_ICatalogCollection interface");

	// populate collection
	hr = (*ppiColl)->Populate();
	if (COMADMIN_E_OBJECTERRORS == hr)
		CpiLogCatalogErrorInfo();
	ExitOnFailure(hr, "Failed to populate collection");

	hr = S_OK;

LExit:
	// clean up
	ReleaseObject(piCatalog);
	ReleaseObject(piDisp);
	ReleaseBSTR(bstrName);
	::VariantClear(&vtKey);

	return hr;
}
Example #20
0
void IEView::clear(IEVIEWEVENT *event) {
#ifdef GECKO
//    pWebBrowser->Navigate(L"www.onet.pl", NULL, NULL, NULL, NULL);
  //  return;
#endif
	IHTMLDocument2 *document = getDocument();
	if (document == NULL) {
		pWebBrowser->Navigate(L"about:blank", NULL, NULL, NULL, NULL);
		HRESULT hr = S_OK;
		IHTMLDocument2 *document = NULL;
		while ((document == NULL) && (hr == S_OK)) {
			Sleep(0);
			IDispatch *dispatch = NULL;
			if (SUCCEEDED(pWebBrowser->get_Document(&dispatch)) && (dispatch != NULL)) {
				hr = dispatch->QueryInterface(IID_IHTMLDocument2, (void **)&document);
				dispatch->Release();
			}
		}
		if (document != NULL) {
			document->Release();
		}
	} else {
		document->close();
		VARIANT		open_name;
		VARIANT		open_features;
		VARIANT		open_replace;
		IDispatch	*open_window	= NULL;
		VariantInit(&open_name);
		open_name.vt      = VT_BSTR;
		open_name.bstrVal = SysAllocString(L"_self");
		VariantInit(&open_features);
		VariantInit(&open_replace);

		HRESULT hr = document->open(SysAllocString(L"text/html"),
		                    open_name,
			                    open_features,
			                    open_replace,
			                    &open_window);
		if (hr == S_OK) {
		//	pWebBrowser->Refresh();
		}
		if (open_window != NULL) {
			open_window->Release();
		}
		document->Release();
	}
	if (builder!=NULL) {
		builder->clear(this, event);
	}
	clearRequired = false;
	getFocus = false;
}
Example #21
0
BOOL 
Foobar::COM_ConnectServer()
{
	HRESULT hr;
	/***** Attach to the running COM instance... *****/
	IDispatch	*pDisp = NULL;
	if(m_comAppH) {
		//try Foobar COMServer2Helper (fast way)
		CALL( m_comAppH->get_Server(&pDisp));
		hr = pDisp->QueryInterface(__uuidof(m_comApp), (void**)&m_comApp);
		RELEASE(pDisp,TRUE);
	}
	else {
		//try GetActive Foobar Object (COMServer2Helper.exe not install right)
		CALL( ObjGet(CLSID_Application07, __uuidof(m_comApp), (void**)&m_comApp));
	}
	if(SUCCEEDED(hr)) {
		DEBUGOUT("Foobar:\t\tServer = ","on");
		// ***** get the Fooar Playback interface...    *****
		CALL( m_comApp->get_Playback(&m_comPlayback) );
		if (m_comPlayback == NULL)
			goto FAILURE;
		// ***** Instantiate an IMIM_fooEventS object. *****
		if(m_comPlaybackEventSink = new IMIM_fooEventS(*this, m_comPlayback, &Foobar::COM_OnEventInvoke)) {

			VARIANT_BOOL bState = VARIANT_FALSE;
			m_comPlayback->get_IsPlaying(&bState);

			m_state = (bState == VARIANT_TRUE) ? PL_PLAYING : PL_STOPPED;
			if(SetActivePlayer(m_index, m_index))
				NotifyInfoChanged();
		}
	}
	else {
		DEBUGOUT("Foobar:\t\tServer = ","off");
		RELEASE(pDisp,TRUE);
		m_state = PL_OFFLINE;
		return FALSE;
	}
	return TRUE;

FAILURE:
  #ifdef DEBUG
	_com_error err(hr);
	OutputDebugString(_T("Foobar:\t\tERROR = COM_ConnectServer()\n\t\t\t"));
	OutputDebugString(err.ErrorMessage());
	OutputDebugString(_T("\n)"));
  #endif
	RELEASE(pDisp,TRUE);
	COM_ReleaseServer();
	return FALSE;
}
Example #22
0
//taken and modified slightly from http://www.wischik.com/lu/programmer/webform.html
IHTMLDocument2* TextRenderBrain::GetDoc()
{ 
	IDispatch *dispatch = NULL;  
	dispatch = MainWndParts::Instance()->mpHtmlView->GetHtmlDocument();
	IHTMLDocument2 *doc = NULL;  

	if (dispatch)
	{
		dispatch->QueryInterface(IID_IHTMLDocument2,(void**)&doc);
		dispatch->Release();
	}
	return doc;
}
Example #23
0
IWebBrowser * CIECoreView::GetGlobalWebBrowser(void)
{
	if ( m_dwCookie == 0 )
	{
		spGIT->RegisterInterfaceInGlobal(GetApplication(),IID_IDispatch,&m_dwCookie);
	}

 	IDispatch *pDisp;
 	spGIT->GetInterfaceFromGlobal(m_dwCookie,IID_IDispatch,(void **)&pDisp);
 	IWebBrowser *pWb = NULL;
 	pDisp->QueryInterface(IID_IWebBrowser,(void **)&pWb);
 	return pWb;
}
Example #24
0
HRESULT AccessibleObject::BuildChildren(std::vector<AccessibleChild>& children,
                                        IAccessible* acc, LPARAM param) {
  if (acc == nullptr)
    acc = acc_;
  if (acc == nullptr)
    return E_INVALIDARG;

  long child_count = 0;
  HRESULT hr = acc->get_accChildCount(&child_count);

  if (FAILED(hr))
    return hr;
  if (child_count == 0)
    return S_FALSE;

  long obtained_count = 0;
  std::vector<VARIANT> var_array(child_count);
  hr = AccessibleChildren(acc, 0L, child_count, var_array.data(),
                          &obtained_count);

  if (FAILED(hr))
    return hr;

  children.resize(obtained_count);
  for (int i = 0; i < obtained_count; i++) {
    VARIANT var_child = var_array[i];

    if (var_child.vt == VT_DISPATCH) {
      IDispatch* dispatch = var_child.pdispVal;
      IAccessible* child = nullptr;
      hr = dispatch->QueryInterface(IID_IAccessible, (void**)&child);
      if (hr == S_OK) {
        GetName(children.at(i).name, CHILDID_SELF, child);
        GetRole(children.at(i).role, CHILDID_SELF, child);
        GetValue(children.at(i).value, CHILDID_SELF, child);
        if (AllowChildTraverse(children.at(i), param))
          BuildChildren(children.at(i).children, child, param);
        child->Release();
      }
      dispatch->Release();

    } else {
      GetName(children.at(i).name, var_child.lVal, acc);
      GetRole(children.at(i).role, var_child.lVal, acc);
      GetValue(children.at(i).value, var_child.lVal, acc);
    }
  }

  return S_OK;
}
Example #25
0
HRESULT CDeskBand::GetIServiceProvider(HWND hwnd, IServiceProvider ** pServiceProvider)
{
    HRESULT hr = E_FAIL;
    if (m_pSite)
        hr = m_pSite->QueryInterface(IID_IServiceProvider, (LPVOID*)pServiceProvider);
    else
    {
        // we don't have a site, so we try finding the explorer window by enumerating
        // all explorer instances and compare that to the parent of hwnd.
        IShellWindows *psw;
        if (SUCCEEDED(CoCreateInstance(CLSID_ShellWindows, NULL, CLSCTX_ALL, IID_IShellWindows, (LPVOID*)&psw)))
        {
            VARIANT v;
            V_VT(&v) = VT_I4;
            IDispatch  *pdisp;
            BOOL fFound = FALSE;
            long count = -1;
            if (SUCCEEDED(psw->get_Count(&count)))
            {
                for (V_I4(&v) = 0; !fFound && (V_I4(&v) < count) && SUCCEEDED(psw->Item(v, &pdisp)); V_I4(&v)++)
                {
                    if (pdisp)
                    {
                        IWebBrowserApp *pwba;
                        if (SUCCEEDED(pdisp->QueryInterface(IID_IWebBrowserApp, (LPVOID*)&pwba)))
                        {
                            HWND hwndWBA;
                            if (SUCCEEDED(pwba->get_HWND((LONG_PTR*)&hwndWBA)))
                            {
                                if ((hwndWBA == hwnd)||(hwndWBA == ::GetParent(hwnd)))
                                {
                                    fFound = TRUE;
                                    hr = pwba->QueryInterface(IID_IServiceProvider, (void**)pServiceProvider);
                                }
                            }
                            pwba->Release();
                        }
                        pdisp->Release();
                    }
                }
            }
            psw->Release();
        }
    }
    return hr;
}
Example #26
0
IHTMLDocument2*  DuiLib::CWebBrowserUI::GetHTMLDocument2()
{
	ASSERT(m_pWebBrowser2);
	IHTMLDocument2* pDoc = NULL;
	IDispatch* pDp =  NULL;
	if(m_pWebBrowser2)
	{
		m_pWebBrowser2->get_Document(&pDp);
		ASSERT(pDp);
		if(pDp)
		{
			pDp->QueryInterface(IID_IHTMLDocument2,(void**)&pDoc);
		}
	}
	
	return pDoc;
}
Example #27
0
HRESULT GetElementByAttribute(IHTMLDocument2 *pDoc, CString szAttributeName, CString szAttributeValue, IHTMLElement** pElem)
{
    IHTMLElementCollection *pColl;
    HRESULT hr = pDoc->get_all(&pColl);

    *pElem = NULL;
    long len;
    pColl->get_length(&len);

    for (int i = 0; i < len; i++)
    {
        VARIANT varName, varIndex;
        varName.vt = VT_UINT;
        varName.lVal = i;
        varIndex.vt = VT_I4;
        varIndex.intVal = 0;

        IDispatch* pDisp; 
        hr = pColl->item(varName, varIndex, &pDisp);
        if (hr == S_OK)
        {
            hr = pDisp->QueryInterface( IID_IHTMLElement, (void**)pElem);
            if (hr == S_OK)
            {                
                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)
                {
                    CString strAttrValue(varAttr.bstrVal);
                    if (strAttrValue == szAttributeValue)
                    {
                        break;
                    }
                }
            }
            *pElem = NULL;
        }
    }

    return hr;
}
LRESULT CIncrementSystemBFDlg::OnMyClickMessage(WPARAM wParam, LPARAM lParam)
{
	
	CComDispatchDriver spScript;
	IDispatch * pDocDisp = NULL;
   
   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 );
		
		pDoc->get_Script(&spScript);

		CComVariant varRet;  
		spScript.Invoke0(L"NoticeClient", &varRet); 

		CComDispatchDriver spData = varRet.pdispVal; 
		CComVariant varValue1;
		spData.GetPropertyByName(L"phone", &varValue1);

		CString strResult = _com_util::ConvertBSTRToString((_bstr_t)varValue1);

		szCharUrl.Format("%s%s", cUrls.QueryPhone, strResult);
		//szCharUrl.Format("http://www.baidu.com/s?wd=%s", strResult);
		//szCharUrl.Format("http://132.90.101.25:7001/portal");
		//szCharUrl.Format("http://132.77.51.11:7700/salemanm/salemanm?service=page/silverservice.silverJobExec.goldUnfinishedFrame&listener=initFrame&PROVINCEID=0011&STAFF_ID=yujp21&PASSWORD=H3B5VVJk0JFroCYwhWHbA9C8yes=&LOGIN_TYPE=KFSYS&inModeCode=1&cond_CONFIG=job&cond_FLAG=all&closeNavMethod=close&JOB_STATUS=1&VALID_FLAG=1&EPARCHY_CODE=0010&SERVER_NUMBER=18612452378");
		 
		CString sResult(_T(""));  
  
		// http://132.77.220.134:8081/window/servlet/CheckSerialNumber?serial_number=132.77.220.134
		

		//CString ip(tempUrl.Left(pos).rig);

		HttpRequestGet("132.77.220.134", 8081, "window/servlet/CheckSerialNumber?serial_number="+strResult, sResult);
		///m_MyIE.Navigate(szCharUrl, NULL, NULL, NULL, NULL);

   		//PostMessage(WM_SIZE,0,0);
   }
   return 1;
}
Example #29
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 #30
0
/**
 * @brief	Updates information about port maps on router.
 */
void UpnpNatAction::UpdateInfo()
{
	HRESULT hResult;

	// Cleanup old port map in case this is an update
	CleanPortMaps();

	// Retrieve current port mappings
	hResult = nat->get_StaticPortMappingCollection(&portMapCollection);
	_ErrorException((hResult != S_OK), "retrieving current port mappings (!= S_OK)", hResult, __LINE__, __FILE__);
	_ErrorException((portMapCollection == NULL), "retrieving current port mappings (NULL)", NULL, __LINE__, __FILE__);

	// Scan through list and load port maps into vector
	// Code is based on MSDN sample
	IUnknown * ptrUnk = NULL;
	hResult = portMapCollection->get__NewEnum(&ptrUnk);
	if (SUCCEEDED(hResult))
	{
		IEnumVARIANT * ptrEnumVar = NULL;
		hResult = ptrUnk->QueryInterface(IID_IEnumVARIANT, (void **) &ptrEnumVar);
		if (SUCCEEDED(hResult))
		{
			VARIANT varCurDevice;
			VariantInit(&varCurDevice);
			ptrEnumVar->Reset();
			// Loop through each port map in the collection
			while (S_OK == ptrEnumVar->Next(1, &varCurDevice, NULL))
			{
				IStaticPortMapping * ptrPortMap = NULL;
				IDispatch * pdispDevice = V_DISPATCH(&varCurDevice);
				if (SUCCEEDED(pdispDevice->QueryInterface(IID_IStaticPortMapping, (void **) &ptrPortMap)))
				{
					// Add port map to vector
					UpnpNatPortMapAction * newPortMap = new (nothrow)UpnpNatPortMapAction(ptrPortMap);
					Utility::DynamicAllocCheck(newPortMap,__LINE__,__FILE__);
					portMaps.Add(newPortMap);						
				}
				VariantClear(&varCurDevice);
			}
			ptrEnumVar->Release();
		}
		ptrUnk->Release();
	}
}