WebBrowser - Delphi

This is a discussion on WebBrowser - Delphi ; I have an application created in D7 which sends a request to a web site and then waits for the response. I tried using third party components such as ICS but had problems with the SSL, so I use a ...

+ Reply to Thread
Results 1 to 6 of 6

WebBrowser

  1. Default WebBrowser

    I have an application created in D7 which sends a request to a web site and
    then waits for the response. I tried using third party components such as
    ICS but had problems with the SSL, so I use a standard TWebBrowser component
    which seems to work fine:

    WebBrowser1.Navigate(WideString('https://www.website.com/program.cfm?param1=something&param2=....),
    flag, flag, flag, flag);

    To get the reponse I use the OnNavigateComplete2 event and once the reponse
    has been processed, it then looks to see if there is another transaction in
    the queue (actually a DBGrid) and if there is, sends another
    WebBrowser1.Navigate method, picks up the reponse via the
    OnNavigateComplete2 event and thus goes round and round until there are no
    more tranasactions to process.

    The only problem is that sometimes it appears to get out of step.

    So my question is this: I have assumed that after the WebBrowser1.Navigate
    method, however long it takes, the next time the OnNavigateComplete2 event
    fires, it will be as a response to the initial WebBrowser1.Navigate method.
    Am I right in this assumption or should I be using the WebBrowser component
    slightly differently?

    Many thanks.



  2. Default Re: WebBrowser

    Tim wrote:
    > I have an application created in D7 which sends a request to a web site and
    > then waits for the response. I tried using third party components such as
    > ICS but had problems with the SSL, so I use a standard TWebBrowser component
    > which seems to work fine:
    >
    > WebBrowser1.Navigate(WideString('https://www.website.com/program.cfm?param1=something&param2=....),
    > flag, flag, flag, flag);
    >
    > To get the reponse I use the OnNavigateComplete2 event and once the reponse
    > has been processed, it then looks to see if there is another transaction in
    > the queue (actually a DBGrid) and if there is, sends another
    > WebBrowser1.Navigate method, picks up the reponse via the
    > OnNavigateComplete2 event and thus goes round and round until there are no
    > more tranasactions to process.
    >
    > The only problem is that sometimes it appears to get out of step.
    >
    > So my question is this: I have assumed that after the WebBrowser1.Navigate
    > method, however long it takes, the next time the OnNavigateComplete2 event
    > fires, it will be as a response to the initial WebBrowser1.Navigate method.
    > Am I right in this assumption or should I be using the WebBrowser component
    > slightly differently?


    If that's not the way your program is working, then clearly your
    assumption was wrong.

    Don't assume you know how a control works, especially not one as
    complicated as Internet Explorer. Read the documentation. If the
    documentation doesn't say something is true or false, assume it could be
    either one depending on whether you're inhaling or exhaling.

    It looks like the NavigateComplete2 event is supposed to tell you the
    URL of the navigation that completed. Can you use that to determine
    which transaction to process the results for? Can you at least use it to
    debug your program and figure out how your assumption was wrong?

    You might try using functions from the UrlMon library instead of
    TWebBrowser since it sounds like you don't really need to display the
    page. Do you need to download the images, stylesheets, and scripts
    associated with the page? Try the UrlOpenStream or UelOpenBlockingStream
    functions.

    --
    Rob

  3. Default Re: WebBrowser

    Once I had the same problem. Here is how I solved it :

    while WebBrowser1.Busy
    do Application.ProcessMessages;

    Flagging such loop so that no re-entrance will be possible is a good
    complement....

    DH

    "Rob Kennedy" <me3@privacy.net> a écrit dans le message de news:
    47c3c805$1@newsgroups.borland.com...
    > Tim wrote:
    >> I have an application created in D7 which sends a request to a web site
    >> and then waits for the response. I tried using third party components
    >> such as ICS but had problems with the SSL, so I use a standard
    >> TWebBrowser component which seems to work fine:
    >>
    >> WebBrowser1.Navigate(WideString('https://www.website.com/program.cfm?param1=something&param2=....),
    >> flag, flag, flag, flag);
    >>
    >> To get the reponse I use the OnNavigateComplete2 event and once the
    >> reponse has been processed, it then looks to see if there is another
    >> transaction in the queue (actually a DBGrid) and if there is, sends
    >> another WebBrowser1.Navigate method, picks up the reponse via the
    >> OnNavigateComplete2 event and thus goes round and round until there are
    >> no more tranasactions to process.
    >>
    >> The only problem is that sometimes it appears to get out of step.
    >>
    >> So my question is this: I have assumed that after the
    >> WebBrowser1.Navigate method, however long it takes, the next time the
    >> OnNavigateComplete2 event fires, it will be as a response to the initial
    >> WebBrowser1.Navigate method. Am I right in this assumption or should I be
    >> using the WebBrowser component slightly differently?

    >
    > If that's not the way your program is working, then clearly your
    > assumption was wrong.
    >
    > Don't assume you know how a control works, especially not one as
    > complicated as Internet Explorer. Read the documentation. If the
    > documentation doesn't say something is true or false, assume it could be
    > either one depending on whether you're inhaling or exhaling.
    >
    > It looks like the NavigateComplete2 event is supposed to tell you the URL
    > of the navigation that completed. Can you use that to determine which
    > transaction to process the results for? Can you at least use it to debug
    > your program and figure out how your assumption was wrong?
    >
    > You might try using functions from the UrlMon library instead of
    > TWebBrowser since it sounds like you don't really need to display the
    > page. Do you need to download the images, stylesheets, and scripts
    > associated with the page? Try the UrlOpenStream or UelOpenBlockingStream
    > functions.
    >
    > --
    > Rob




  4. Default Re: WebBrowser

    Hi Rob,

    > If that's not the way your program is working, then clearly your
    > assumption was wrong.


    Difficult to argue against.

    > Don't assume you know how a control works, especially not one as
    > complicated as Internet Explorer. Read the documentation. If the
    > documentation doesn't say something is true or false, assume it could be
    > either one depending on whether you're inhaling or exhaling.
    >
    > It looks like the NavigateComplete2 event is supposed to tell you the URL
    > of the navigation that completed. Can you use that to determine which
    > transaction to process the results for? Can you at least use it to debug
    > your program and figure out how your assumption was wrong?


    I may be able to. I will need to investigate further.

    > You might try using functions from the UrlMon library instead of
    > TWebBrowser since it sounds like you don't really need to display the
    > page. Do you need to download the images, stylesheets, and scripts
    > associated with the page? Try the UrlOpenStream or UelOpenBlockingStream
    > functions.


    I will look at these.

    Many thanks for such clear, logical thinking.

    Tim



  5. Default Re: WebBrowser

    Thanks, I will look at this.

    Tim

    "HAROUCHE, David" <metanil@hotmail.com> wrote in message
    news:47c3c96c@newsgroups.borland.com...
    > Once I had the same problem. Here is how I solved it :
    >
    > while WebBrowser1.Busy
    > do Application.ProcessMessages;
    >
    > Flagging such loop so that no re-entrance will be possible is a good
    > complement....
    >
    > DH
    >
    > "Rob Kennedy" <me3@privacy.net> a écrit dans le message de news:
    > 47c3c805$1@newsgroups.borland.com...
    >> Tim wrote:
    >>> I have an application created in D7 which sends a request to a web site
    >>> and then waits for the response. I tried using third party components
    >>> such as ICS but had problems with the SSL, so I use a standard
    >>> TWebBrowser component which seems to work fine:
    >>>
    >>> WebBrowser1.Navigate(WideString('https://www.website.com/program.cfm?param1=something&param2=....),
    >>> flag, flag, flag, flag);
    >>>
    >>> To get the reponse I use the OnNavigateComplete2 event and once the
    >>> reponse has been processed, it then looks to see if there is another
    >>> transaction in the queue (actually a DBGrid) and if there is, sends
    >>> another WebBrowser1.Navigate method, picks up the reponse via the
    >>> OnNavigateComplete2 event and thus goes round and round until there are
    >>> no more tranasactions to process.
    >>>
    >>> The only problem is that sometimes it appears to get out of step.
    >>>
    >>> So my question is this: I have assumed that after the
    >>> WebBrowser1.Navigate method, however long it takes, the next time the
    >>> OnNavigateComplete2 event fires, it will be as a response to the initial
    >>> WebBrowser1.Navigate method. Am I right in this assumption or should I
    >>> be using the WebBrowser component slightly differently?

    >>
    >> If that's not the way your program is working, then clearly your
    >> assumption was wrong.
    >>
    >> Don't assume you know how a control works, especially not one as
    >> complicated as Internet Explorer. Read the documentation. If the
    >> documentation doesn't say something is true or false, assume it could be
    >> either one depending on whether you're inhaling or exhaling.
    >>
    >> It looks like the NavigateComplete2 event is supposed to tell you the URL
    >> of the navigation that completed. Can you use that to determine which
    >> transaction to process the results for? Can you at least use it to debug
    >> your program and figure out how your assumption was wrong?
    >>
    >> You might try using functions from the UrlMon library instead of
    >> TWebBrowser since it sounds like you don't really need to display the
    >> page. Do you need to download the images, stylesheets, and scripts
    >> associated with the page? Try the UrlOpenStream or UelOpenBlockingStream
    >> functions.
    >>
    >> --
    >> Rob

    >
    >




  6. Default Re: WebBrowser


    "Tim" <tim@evolvedatasystems.co.uk> wrote in message
    news:47c3bdd7$1@newsgroups.borland.com...

    > I have assumed that after the WebBrowser1.Navigate method,
    > however long it takes, the next time the OnNavigateComplete2
    > event fires, it will be as a response to the initial WebBrowser1.Navigate
    > method.


    Yes, though it may not report the same URL that you originally requested.

    > should I be using the WebBrowser component slightly differently?


    OnNavigateComplete2 is not triggered if the navigation fails. Try the
    OnDocumentComplete event.


    Gambit



+ Reply to Thread