IID_IHTMLElement Failing
-
Hi, I am trying to get IID_IHTMLElement but its failing, in few cases. The GetlastError function returns 0 for these cases. I am using following function call to achive this, IHTMLElement * pElement = NULL; IHTMLDocument2 * pHTMLDoc = NULL; HRESULT hr; IServiceProvider * pSP = NULL; hr = pAccWindow->QueryInterface(IID_IServiceProvider, (void **)&pSP); hr = pSP->QueryService(IID_IHTMLElement, IID_IHTMLElement, (void **)&pElement); I do not get any exception, bur I getting pElement as NULL. I got these failure when I press the Browser BACK button in MSIE 6.0. Any pointer will be helpful, Thanks in Advance ARLahare
-
Hi, I am trying to get IID_IHTMLElement but its failing, in few cases. The GetlastError function returns 0 for these cases. I am using following function call to achive this, IHTMLElement * pElement = NULL; IHTMLDocument2 * pHTMLDoc = NULL; HRESULT hr; IServiceProvider * pSP = NULL; hr = pAccWindow->QueryInterface(IID_IServiceProvider, (void **)&pSP); hr = pSP->QueryService(IID_IHTMLElement, IID_IHTMLElement, (void **)&pElement); I do not get any exception, bur I getting pElement as NULL. I got these failure when I press the Browser BACK button in MSIE 6.0. Any pointer will be helpful, Thanks in Advance ARLahare
-
Hi, I am trying to get IID_IHTMLElement but its failing, in few cases. The GetlastError function returns 0 for these cases. I am using following function call to achive this, IHTMLElement * pElement = NULL; IHTMLDocument2 * pHTMLDoc = NULL; HRESULT hr; IServiceProvider * pSP = NULL; hr = pAccWindow->QueryInterface(IID_IServiceProvider, (void **)&pSP); hr = pSP->QueryService(IID_IHTMLElement, IID_IHTMLElement, (void **)&pElement); I do not get any exception, bur I getting pElement as NULL. I got these failure when I press the Browser BACK button in MSIE 6.0. Any pointer will be helpful, Thanks in Advance ARLahare
Without knowing anything about this, I did a quick SDK search. This sample code (and similar code found on Google) seems to be common -
// from "About Active Accessibility Support" in the PSDK
HRESULT hr;
IHTMLWindow2 * pWindow;
IHTMLElement * pElement;
hr = pSP->QueryService(IID_IHTMLWindow2, IID_IHTMLWindow2,
(void **)&pWindow);
if (FAILED(hr))
hr = pSP->QueryService(IID_IHTMLElement, IID_IHTMLElement,
(void **)&pElement);// Release the Service Provider interface pointer.
pSP->Release();if (SUCCEEDED(hr))
{
// Either a window or an element pointer was returned.
assert( pWindow || pElement);
....
code here...
// Release the pointers.
if (pElement)
pElement->Release();
if (pWindow)
pWindow->Release();
}Maybe that helps? Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
-
Hi, I am trying to get IID_IHTMLElement but its failing, in few cases. The GetlastError function returns 0 for these cases. I am using following function call to achive this, IHTMLElement * pElement = NULL; IHTMLDocument2 * pHTMLDoc = NULL; HRESULT hr; IServiceProvider * pSP = NULL; hr = pAccWindow->QueryInterface(IID_IServiceProvider, (void **)&pSP); hr = pSP->QueryService(IID_IHTMLElement, IID_IHTMLElement, (void **)&pElement); I do not get any exception, bur I getting pElement as NULL. I got these failure when I press the Browser BACK button in MSIE 6.0. Any pointer will be helpful, Thanks in Advance ARLahare
From my experience the
IHTMLElement
interface is not accessed viaIServiceProvider
but simply viaQueryInterface
on the element in question.GetLastError
is not used for error handling in COM: COM is designed with remote access in mind and theGetLastError
mechanism is thread specific. In your code what ispAccWindow
?Steve
-
From my experience the
IHTMLElement
interface is not accessed viaIServiceProvider
but simply viaQueryInterface
on the element in question.GetLastError
is not used for error handling in COM: COM is designed with remote access in mind and theGetLastError
mechanism is thread specific. In your code what ispAccWindow
?Steve
Thanks Stephen, I have seen code samples where IServiceProvider is used to accesses IHTMLElement and its working in my code for other cases. pAccWindow is the IAccessible pointer. Thanks for your help ARLahare
-
Abhi Lahare wrote:
The GetlastError function returns 0 for these cases.
You need to diagnose the HRESULT
led mike
Return value is E_INVALIDARG but not sure what is wrong with input parameter. Regards ARLahare
-
Return value is E_INVALIDARG but not sure what is wrong with input parameter. Regards ARLahare
According to the docs, the object "can be an element or a window". Have you tried querying for IID_IHTMLWindow2 first as documented? Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
-
According to the docs, the object "can be an element or a window". Have you tried querying for IID_IHTMLWindow2 first as documented? Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
yes