scrolling in an IE add-on



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

.



Relevant Pages

  • Re: Need to use VBA to put image on a form
    ... Earl Kiosterud ... the OP can place an Image control, ... this way the form's native ScrollBars can be used to scroll the contents of the Image ... Note: Some folks prefer bottom-posting. ...
    (microsoft.public.access.formscoding)
  • Re: How do you interactively write to a CEditView Window
    ... When you scroll the ... the window flashes a lot. ... and trying to control the flashing and deal with the user resetting ... note that sizeof() a string will include the NUL character, while what you really want is ...
    (microsoft.public.vc.mfc)
  • Re: Cannot enter edit boxes on CProperty pages
    ... Are you trying to make the propretysheet scroll, ... tab control to switch pages and on a PC an OK button. ... to an edit box with mouse and edit it, nor does it seem tab keyboard ... not on WinCE device ...
    (microsoft.public.vc.mfc)
  • Re: ASP.Net 2.0 and partial classes
    ... to the Designer where he or she must select a control and scroll, scroll, ... What was the name of that control again? ... Back to the Designer to scroll, ... the partial class using commented signatures for each control. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Best Way To Design Form w/Hundreds of Yes/No Fields
    ... picturebox and scroll bars), and after the Dim statements in the form load ... The user can scroll the questions into view, ... but it uses 1 control to ... I'm working on designing a data entry form for a client. ...
    (comp.lang.basic.visual.misc)

Loading