pitagora
08-03-2005, 03:25 PM
i'm trying to get a IHTMLWindow2 object to use it's Scroll method. It's realy weird but it doesn't work. Here is the code i used.
m_pWebBrowser is IWebBrowser2* and has been corectly initialized...as in i can use it to control the IE window (Navigate...parse the source...).
HRESULT hr;
IDispatch* pHtmlDocDispatch = NULL;
IHTMLDocument2 * pHtmlDoc = NULL;
IHTMLWindow2 * p = NULL;
hr = m_pWebBrowser->get_Document (&pHtmlDocDispatch);
if (SUCCEEDED (hr) && (pHtmlDocDispatch != NULL))
{
hr = pHtmlDocDispatch->QueryInterface (IID_IHTMLDocument2, (LPVOID *) &pHtmlDoc);
if (SUCCEEDED (hr) && (pHtmlDoc != NULL))
{
pHtmlDoc->get_parentWindow(&p);
// this is were i get the error. p remains null
if(SUCCEEDED(hr) && p)
p->scrollTo(x,y);
}
}
I realy hope some1 can help or at least give me an alternative way to scroll the IE window..other then sending keys.
m_pWebBrowser is IWebBrowser2* and has been corectly initialized...as in i can use it to control the IE window (Navigate...parse the source...).
HRESULT hr;
IDispatch* pHtmlDocDispatch = NULL;
IHTMLDocument2 * pHtmlDoc = NULL;
IHTMLWindow2 * p = NULL;
hr = m_pWebBrowser->get_Document (&pHtmlDocDispatch);
if (SUCCEEDED (hr) && (pHtmlDocDispatch != NULL))
{
hr = pHtmlDocDispatch->QueryInterface (IID_IHTMLDocument2, (LPVOID *) &pHtmlDoc);
if (SUCCEEDED (hr) && (pHtmlDoc != NULL))
{
pHtmlDoc->get_parentWindow(&p);
// this is were i get the error. p remains null
if(SUCCEEDED(hr) && p)
p->scrollTo(x,y);
}
}
I realy hope some1 can help or at least give me an alternative way to scroll the IE window..other then sending keys.