🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.internet.web
3 messages
3 total messages Started by Brian Thu, 16 Nov 2006 22:55
Finding out if browser has been scrolled
#530
Author: Brian
Date: Thu, 16 Nov 2006 22:55
41 lines
2059 bytes
Hi,

I'm trying to find out if a TCppWebBrowser component has been scrolled 
vertically. I do this by finding the body tag and getting the scrollTop 
property. It works with many pages, but also fail with quite a few 
(get_scrollTop gets the value 0). What am I doing wrong? Navigating to a 
page like www.freebsd.org and scrolling it before all images have been 
loaded will cause get_scrollTop to return 0 when the downloading has 
completed.

      IHTMLDocument2 *Doc;
      if(SUCCEEDED(web->Document->QueryInterface(IID_IHTMLDocument2, 
(LPVOID*)&Doc)))
      {
        IHTMLElement *lpBodyElm = NULL;
        IHTMLElement2 *lpBody  = NULL;

        try
        {
         if( SUCCEEDED(Doc->get_body(&lpBodyElm)) )
         {
          if( 
SUCCEEDED(lpBodyElm->QueryInterface(IID_IHTMLElement2,(void**)&lpBody)) )
          {
           if( !SUCCEEDED(lpBody->get_scrollTop( &current_y)) )
           {
            // never seem to happen
           }
           lpBody->Release();
          }
          lpBodyElm->Release();
         }
        }
        catch(...)
        {
        }
     }


Thanks in advance,
Brian
Re: Finding out if browser has been scrolled
#531
Author: Remy Lebeau (TeamB)
Date: Fri, 17 Nov 2006 03:37
20 lines
1539 bytes
"Brian" <no@spam.please.com> wrote in message
news:455cec6e$1@newsgroups.borland.com...

> Navigating to a page like www.freebsd.org and scrolling it before
> all images have been loaded will cause get_scrollTop to return 0 when
> the downloading has completed.

Where exactly are you calling the code from?  Are you waiting for the
OnDocumentComplete event to trigger before doing anything?

>            if( !SUCCEEDED(lpBody->get_scrollTop( &current_y)) )
>            {
>             // never seem to happen
>            }

You are testing for "not succeeded".  Is that what you really wanted?


Gambit
Re: Finding out if browser has been scrolled
#532
Author: Brian
Date: Fri, 17 Nov 2006 08:21
28 lines
1606 bytes
Hi Remy,

> Where exactly are you calling the code from?  Are you waiting for the
> OnDocumentComplete event to trigger before doing anything?

After calling Navigate, I wait until readystate is complete:

while(web->ReadyState!=Shdocvw_tlb::READYSTATE_COMPLETE)
{
    Application->ProcessMessages();
    ::Sleep(50);
}



>>    if( !SUCCEEDED(lpBody->get_scrollTop( &current_y)) )
>>    {
>>     // never seem to happen
>>    }
> 
> You are testing for "not succeeded".  Is that what you really wanted?

Yes, it was just a test. I had a popup message there to see if 
the call to get_scrollTop failed on the pages where it returns 0. 
It doesn't.

Thanks,
Brian
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads