Newsgroups : Borland : borland.public.delphi.internet.winsock : 2006 Jun : Re: TWebBrowser multiple pages

www.cryer.info
Managed Newsgroup Archive

Re: TWebBrowser multiple pages

Subject:Re: TWebBrowser multiple pages
Posted by:"Remy Lebeau (TeamB)" (no.spam@no.spam.com)
Date:Thu, 1 Jun 2006 11:11:37

"Bob Bedford" <bob@bedford.com> wrote in message
news:447ee111@newsgroups.borland.com...

> Now, I'm stuck. How to navigate to such new links as I need
> to retrieve some datas from there ? I try to do a Navigate again
> but nothing appends. I've tried this code:

You need to wait for the first Navigate() to finish before you can access
the contents of the TStringList.  You are not doing that.  For example:

    FInternetExplorer.Navigate(edtURL.Text, EmptyParam,
EmptyParam,EmptyParam,

    // Add This!!
    while FInternetExplorer.ReadyState < READYSTATE_COMPLETE do
        Application.ProcessMessages;

    for I:=0 to pages.Count-1 do begin
        //...

Otherwise, you will have to move your link processing into the
OnDocumentComplete event handler instead, ie:

    FInternetExplorer.Navigate(edtURL.Text, EmptyParam, EmptyParam,
EmptyParam, EmptyParam);

    procedure TForm1.FInternetExplorerDocumentComplete(Sender: TObject;
pDisp: IDispatch; var URL: Variant);
    var
        pages: TStringList;
        I: Integer;
    begin
        pages := TStringList.Create;
        try
            // fill pages as needed, then ...
            for I := 0 to pages.Count-1 do
                FInternetExplorer.Navigate(pages[I], EmptyParam, EmptyParam,
EmptyParam, EmptyParam);
        finally
            pages.Free;
        end;
    end;

> As I've seen on a forum that it's the way to wait until the browser
> has finished everything, but it doesn't work.

READYSTATE_INTERACTIVE is too soon.  It can be reached before all of the
data is available.  You need to wait for READYSTATE_COMPLETE instead.


Gambit

Replies:

none

In response to:

www.cryer.info
Managed Newsgroup Archive