Link to home
Start Free TrialLog in
Avatar of Leo01010101
Leo01010101

asked on

How to use CppWebBrowser->Navigate() in a loop to send inquirys and catch answers sequentially?

I want to send several inquires using CppWebBrowser->Navigate() ( in loop ) and catch answers by HTMLDocument. I'm not sure how to make it in BCB6. When waiting in a loop, event OnDocumentComplete not fire. When run a single ( not  in a loop - it's working) .
Avatar of George Tokas
George Tokas
Flag of Greece image

Hi again,
In order to get my "attention" send me a mail to check it out instead of using "neglected..." method...
Now:
In the loop are you using Application->ProcessMessages() ??
I mean:
for()
{
  .....whatever code here...
 Application->ProcessMessages();
}
If not then OnDocumentComplete will not be triggered. In fact it will be but will not be processed...
Is your CppWebBrowser visible as object in the form?
If not then there are and other - faster - ways around (with BCB6 not later)...

George Tokas.
Avatar of Leo01010101
Leo01010101

ASKER

Thank you again,

I made a simple code for reading positions for trip ends and write it into database. It looks
in this way :

if( number_of_records > 0 )
   {
     MapShowForm->ProgressBar1->Max = number_of_records;
     MapShowForm->ProgressBar1->Min = 0;
     MapShowForm->ProgressBar1->Position = 0;

     AdcDataModule->RecordQuery->First();

     while( !AdcDataModule->RecordQuery->Eof )
     {
       AnsiString url_txt = SetUrlAddress( AdcDataModule->RecordQuery->FieldByName("LATITUDE")->AsFloat,
                                           AdcDataModule->RecordQuery->FieldByName("LONGITUDE")->AsFloat );

       CppWebBrowser1->Navigate( WideString(url_txt).c_bstr(), NULL, NULL, NULL, NULL);

       Application->ProcessMessages();
     }


     MapShowForm->ProgressBar1->Position = 0;
     MapShowForm->Close();
   }

Open in new window


I place proposed code but no results. OnDocumentComplete didn't fire.
In this solution CppWebBrowser could be invisible.
ASKER CERTIFIED SOLUTION
Avatar of George Tokas
George Tokas
Flag of Greece image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Now works, but is problem when answer didn't come - it stops and can't continue. Maybe should add protection for time of one operation and than break while(!DocComplete)?
Yes that is true and needed...
We had to make it work first...
You can use a TTimer as timeout method...
That is what I am doing all the time...
But I am trying to avoid the use of CppWebBrowser because it has the habit to download and images, flash files and so on...

George Tokas.
Is the other method to download answer I'm catching now without using CppWebBrowser?
The other method uses TNMHTTP from netmasters tab...
Downloading as a text (header and body) and nothing else...
Usually is faster and can be implemented inside a class with a timeout...

George Tokas.
In your opinion which one is better for using for this kind of application?
CppWebBrowser is a wrapper around Internet Explorer with all pros and cons...
If you need to display a page of course you need to use TCppWebBrowser...
Doesn't mean though that it will be your component for other works...
On the other hand TNMHTTP is a component that just "reads" the content and also provides download features.
I am keen to work with TNMHTTP when there is no need of displaying...
A major drawback though is that netmasters tab doesn't exists in later versions than 6. There are available if you pay for the package...
Maybe it is needed from me to create a set of that kind of packages in the near future for my articles...

George Tokas
I'm using ActiveSocket component from ActiveExperts  ( I used it mainly for ftp ). There are included also HTTP component. I will check it and try to read this data by using this component.

Thank you for your help, next time will get your "attention" by e-mail.
You are welcome...
Also because I am monitoring all topics I am posting just drop a post here - example - or anywhere else...

George Tokas.