Quantcast
Channel: Internet Explorer Web Development forum
Viewing all articles
Browse latest Browse all 3527

Cannot get the IWindowForBindingUI interface on an Ajax request in Asynchronous Pluggable Protocol

$
0
0

I have read a bunch of forum posts about this problem and the solution that is always provided by Igor is to call Switch on the IInternetProtocolSink interface and then to try and get this interfance on the UI thread in the Continue method. I have done this and it is solving the problem for all non-top level requests except for AJAX requests. Here is the code that attempts to get the IWindowForBindingUI interface in case that is helpful. This is called from inside the Continue method.

HWND CManagedAppBridge::RetrieveIEServerHwnd(IInternetProtocolSink *pOIProtSink) { #if DEBUG_ORIGINAL ATLTRACE(_T("CManagedAppBridge::RetrieveIEServerHwnd\tBegin\n")); #endif HWND hwnd = NULL; CComPtr<IWindowForBindingUI> objWindowForBindingUI; HRESULT hr = IUnknown_QueryService(pOIProtSink, IID_IWindowForBindingUI, IID_IWindowForBindingUI, (void**)&objWindowForBindingUI); if( (SUCCEEDED(hr)) && (objWindowForBindingUI) ) { //Should return InternetExplorerServer HWND //objWindowForBindingUI->GetWindow(IID_IHttpSecurity, &hwnd); } else // Try to get at the IWindowForBindingUI a different way. { CComPtr<IServiceProvider> piServiceProvider = NULL; hr = pOIProtSink->QueryInterface(&piServiceProvider); if (SUCCEEDED(hr) && (piServiceProvider != NULL)) { ///*hr = IUnknown_QueryService(pOIProtSink, //*/ IID_IWindowForBindingUI, IID_IWindowForBindingUI, (void**)&objWindowForBindingUI); hr = piServiceProvider->QueryInterface(&objWindowForBindingUI); } } if (SUCCEEDED(hr) && (objWindowForBindingUI != NULL)) objWindowForBindingUI->GetWindow(IID_IHttpSecurity, &hwnd);

return hwnd;
}


Any ideas on what to try next? If helpful I would be willing to try and submit a small project that reproduces the problem. I have been looking at this for a couple days now.

For reference, this is the code that calls the Switch method:

	m_protocolData.grfFlags = PD_FORCE_SWITCH;
		m_protocolData.dwState = 0x444;
		m_protocolData.pData = NULL;
		m_protocolData.cbData = 0;
		pOIProtSink->Switch(&m_protocolData);
		hResult = S_OK;
		goto Return;

And here is the Continue method:

STDMETHODIMP CManagedAppBridge::Continue(PROTOCOLDATA *pProtocolData)
{
#if DEBUG_DOWNLOADER || DEBUG_REQUESTS
	ATLTRACE(_T("%4x\tIInternetProtocolRoot::Continue - %s\n"), ::GetCurrentThreadId(), m_pszOriginalUrl);
#endif

	// This will be called from inside Start on a worker thread when we need to get the window handle of the IE thread.
	if (pProtocolData->dwState == 0x444)
	{
		HWND hwndIEServer = RetrieveIEServerHwnd(m_spInternetProtocolSink);
		if (hwndIEServer == NULL)
		{
			OutputDebugString(L"Did not get the window handle: ");
			OutputDebugString(m_pszOriginalUrl);
			OutputDebugString(L"\n");
			hwndIEServer = RetrieveIEServerHwnd(m_spInternetProtocolSink);
		}
		HRESULT hResult = StartForReal(hwndIEServer, FALSE);
		return hResult;
	}

	if(m_bClientHandled == VARIANT_TRUE)
	{
#if DEBUG_ORIGINAL
		ATLTRACE(_T("%4x - CManagedAppBridge-Continue-ClientHandled-Url=%s\n"), ::GetCurrentThreadId(), m_pszOriginalUrl);
#endif
		return S_OK;
	}
	else
	{
#if DEBUG_ORIGINAL
		ATLTRACE(_T("%4x - CManagedAppBridge-Continue-Url=%s\n"), ::GetCurrentThreadId(), m_pszOriginalUrl);
#endif
		ATLASSERT(m_spInternetProtocol != 0);
		return m_spInternetProtocol ?
			m_spInternetProtocol->Continue(pProtocolData) :
			E_UNEXPECTED;
	}
}





Viewing all articles
Browse latest Browse all 3527

Trending Articles