Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1166
  • Last Modified:

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) .
0
Leo01010101
Asked:
Leo01010101
  • 6
  • 5
1 Solution
 
George TokasCommented:
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.
0
 
Leo01010101Author Commented:
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.
0
 
George TokasCommented:
Lets try this:
Declare a global boolean in the form header.
bool DocComplete;

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

       DocComplete = 0;
       CppWebBrowser1->Navigate( WideString(url_txt).c_bstr(), NULL, NULL, NULL, NULL);
       while(!DocComplete)
       {
         Application->ProcessMessages();
        }
     }
And add in OnDocumentComplete handler:
DocComplete = 1;
This way you are waiting for the page to complete download before go to the next in loop.
Lets see...
If this will not work I have and other trics to propose...

George Tokas.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
Leo01010101Author Commented:
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)?
0
 
George TokasCommented:
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.
0
 
Leo01010101Author Commented:
Is the other method to download answer I'm catching now without using CppWebBrowser?
0
 
George TokasCommented:
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.
0
 
Leo01010101Author Commented:
In your opinion which one is better for using for this kind of application?
0
 
George TokasCommented:
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
0
 
Leo01010101Author Commented:
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.
0
 
George TokasCommented:
You are welcome...
Also because I am monitoring all topics I am posting just drop a post here - example - or anywhere else...

George Tokas.
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 6
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now