scrolling in an IE add-on
- From: vsimionescu@xxxxxxxxxx
- Date: Fri, 19 Oct 2007 03:05:19 -0700
Hello
I know this question has been asked before in this group. I'm having
problems obtaining the scroll position in an IE add-on, and then
scrolling. But let's first focus on obtaining the position. I've tried
the method I found right here and that seemed to me it's the most
recommended, namely via IHTMLDocument2::get_body, and
IHTMLTextContainer::get_scrollTop . It doesn't work; more
specifically, it works on some web pages such as
http://news.google.com/nwshp?tab=wn
but doesn't work on others, including the Google and Yahoo main pages.
I don't know, I may be doing something wrong but I don't think so,
since sometimes it works. But it's a possibility of course. So here's
how I obtain the IHTMLTextContainer pointer:
IHTMLTextContainer* GetIHTMLTextContainer (IHTMLDocument2* apDocument)
{
assert (apDocument != NULL);
IHTMLElement* htmlBody = NULL;
if (apDocument->get_body (&htmlBody) != S_OK)
return NULL;
if (htmlBody == NULL)
return NULL;
IHTMLTextContainer* pHTMLText = NULL;
htmlBody->QueryInterface (
IID_IHTMLTextContainer, (void **)&pHTMLText);
htmlBody->Release();
return pHTMLText;
}
then I use it like
pHTMLText->get_scrollTop (&pos);
pHTMLText->get_scrollHeight (&range);
get_scrollHeight always returns a non-0 integer I suppose is correct,
but pos is always 0 on those pages that don't work, even if the scroll
is not at 0. On the pages that work, the scroll pos is OK, of course.
So, I wonder if anybody has met this problem and knows how to deal
with it. Please tell me if so. Also if you spot some error in my code
sample.
Also, maybe there's another more reliable (actually, that is: very
reliable) way of scrolling. I've searched for it but couldn't find it.
I tried pretty hard to do it via windows functions, that is obtain a
HWND for the control that has the scroll bar, then use Windows scroll
functions. It didn't work, I believe I did obtain the control but
couldn't get the scroll info (but I'm not sure, maybe it wasn't the
right control). I imagine there should be a way, what the hell, it's
just a control with a scroll bar, it shouldn't depend on the page
that's underneath.
Regards
V. Simionescu
.
- Follow-Ups:
- Re: scrolling in an IE add-on
- From: Igor Tandetnik
- Re: scrolling in an IE add-on
- Prev by Date: Re: IDocHostUIHandler GetExternal question
- Next by Date: Re: scrolling in an IE add-on
- Previous by thread: IDocHostUIHandler GetExternal question
- Next by thread: Re: scrolling in an IE add-on
- Index(es):
Relevant Pages
|
Loading