 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Eduardo Jauch Guest
|
Posted: Tue Feb 06, 2007 10:47 pm Post subject: TCPPWebBrowser SLOW for a certain time of day |
|
|
Hi!
I make a program that works perfectly! (almost LOL)
Any way, on certain times of day the pages are loaded VERY slowly.
The IE too are very slowly to LOAD the pages...
I think first about traffic on the site.
But I then used the Firefox, and no problem!!!
The same pages are download in about 2 seconds in firefox, while in IE
can take to 2 minutes!!!!!!!!!
The IE 6 (is that I use), have to access some server in certain times or
for some reason, like the MSN?
Was not my code I think, but anyway, I do this:
The code is this:
This is the code that Load the pages...
void TjanelaPrincipal::CarregarFrame(WideString url)
{
TVariant FrameName( "iContent" );
paginaCarregada = false;
Browser->Navigate( url, TNoParam(), &FrameName );
while( !paginaCarregada )
{
Application->ProcessMessages();
}
}
paginaCarregada (this mean: pageLoaded) is changed this way:
void __fastcall TjanelaPrincipal::BrowserNavigateComplete2(TObject *Sender,
LPDISPATCH pDisp, Variant *URL)
{
if (!CurDispatch)
CurDispatch = pDisp;
}
//---------------------------------------------------------------------------
void __fastcall TjanelaPrincipal::BrowserDocumentComplete(TObject *Sender,
LPDISPATCH pDisp, Variant *URL)
{
if (pDisp == CurDispatch)
{
CurDispatch = NULL;
FrameDoc = Frame( WideString("iContent") );
if( FrameDoc )
FrameDoc->get_all( &All );
else
{
ShowMessage("ERRO!!! \'Frame\' não encontrado!");
return;
}
if( !All )
{
FrameDoc->Release();
ShowMessage("ERRO!!! \'All\' não encontrado!");
return;
}
paginaCarregada = true;
}
else
{
paginaCarregada = false;
}
}
Any better ideas to do this?
I cannot put my code direct in BrowserDocumentComplete, for various
reasons....
One is that I use this code:
int TjanelaPrincipal::Agendamento(void)
{
IDispatch *pDisp;
IHTMLInputElement *pInput;
IHTMLSelectElement *pSelect;
IHTMLOptionElement *pOption;
TAGIntervalo *pIntervalo;
WideString opcao;
AnsiString qtde;
long pItens;
int i, m, d, h, qtde_n;
meses.Reiniciar();
datas.Reiniciar();
pSelect = SelectElement("mesDisponivel");
pSelect->get_length( &pItens );
for( i = 1; i < pItens; i++ )
{
pOption = OptionElement( pSelect, i );
if( !pOption ) return -1;
pOption->get_text( &opcao );
pOption->Release();
meses.AdicionarData( opcao );
info_mm->Lines->Add( "MÊS: " + AnsiString(opcao) );
}
pSelect->Release();
int prxMes;
int prxData;
for( m = 0; m < meses.MesesAptos; m++ )
{
pSelect = SelectElement( "mesDisponivel" );
if( !pSelect ) return -1;
prxMes = meses.IndiceProximaData;
if( prxMes == -1 ) return 0;
pSelect->put_selectedIndex( prxMes );
pSelect->Release();
datas.Reiniciar();
CarregarFrame( "javascript: popularListaDiasDisponiveis()" );
//Carrega os dias para o MÊS selecionado
pSelect = SelectElement( "diaDisponivel" );
if( !pSelect ) return -1;
pSelect->get_length(&pItens);
for(i = 1; i < pItens; i++)
{
pOption = OptionElement( pSelect, i );
if( !pOption ) return -1;
pOption->get_text( &opcao );
pOption->Release();
datas.AdicionarData( opcao ); //save the date
info_mm->Lines->Add( " Data: " + AnsiString(opcao) );
}
pSelect->Release();
//Vasculha os dias para encontrar um apto
for( d = 0; d < datas.DatasAptas; d++)
{
pSelect = SelectElement( "diaDisponivel" );
if( !pSelect ) return -1;
prxData = datas.IndiceProximaData;
if( prxData == -1 ) break;
pSelect->put_selectedIndex( prxData ); //Get next date if there
are some interesting.
pSelect->Release();
CarregarFrame( "javascript: popularListaHorariosDisponiveis()" );
pSelect = SelectElement( "seqHorarioAgendamentoDisponivel" );
if( !pSelect ) return false;
pSelect->get_length( &pItens );
for( i = 1; i < pItens; i++ )
{
pOption = OptionElement( pSelect, i );
if( !pOption ) break;
pOption->get_text(&opcao);
pOption->Release();
//info_mm->Lines->Add( datas.DataStr[prxData] + ":" +
AnsiString(opcao) );
if(opcao.Length() == 3
qtde = opcao.SubString(28, 2);
else
qtde = opcao.SubString(28, 1);
qtde_n = qtde.ToInt();
if(qtde_n >= requerentes->Count)
{
pSelect->put_selectedIndex(i);
CarregarFrame( "javascript: confirmarAgendamento()" );
pSelect = SelectElement( "seqHorarioAgendamentoDisponivel" );
if( pSelect )
{
i = 1;
}
else
{
return 1; //Conseguiu AGENDAR
}
}
}
pSelect->Release();
}
}
return 0; //Acabou a lista
}
Theres some component like TCppWebBrowser, but that uses firefox or
other browser?
Any ideas???
Thanks!  |
|
| Back to top |
|
 |
Hans Galema Guest
|
Posted: Tue Feb 06, 2007 11:00 pm Post subject: Re: TCPPWebBrowser SLOW for a certain time of day |
|
|
Eduardo Jauch wrote:
| Quote: | The same pages are download in about 2 seconds in firefox, while in IE
can take to 2 minutes!!!!!!!!!
|
So TCppWebBRowser is slow, IE is slow and Firefox is fast.
| Quote: | Was not my code I think, but anyway, I do this:
void TjanelaPrincipal::CarregarFrame(WideString url)
{
TVariant FrameName( "iContent" );
paginaCarregada = false;
Browser->Navigate( url, TNoParam(), &FrameName );
while( !paginaCarregada )
{
Application->ProcessMessages();
}
}
|
Is that code that loads a htmppage in one of the frames of an existing
page? Why didn't you tell?
What is the use of paginaCarregada ? I think you can omit it all the way.
And at least the loop with Application->ProcessMessages(); looks not needed.
| Quote: | void __fastcall TjanelaPrincipal::BrowserNavigateComplete2(TObject *Sender,
LPDISPATCH pDisp, Variant *URL)
{
if (!CurDispatch)
CurDispatch = pDisp;
}
|
You did explain nothing of CurDispath? What is it? Where did you assign it?
Why this code?
| Quote: | void __fastcall TjanelaPrincipal::BrowserDocumentComplete(TObject *Sender,
LPDISPATCH pDisp, Variant *URL)
{
if (pDisp == CurDispatch)
{
CurDispatch = NULL;
FrameDoc = Frame( WideString("iContent") );
|
You did not explain the function Frame().
| Quote: |
if( FrameDoc )
FrameDoc->get_all( &All );
else
{
ShowMessage("ERRO!!! \'Frame\' não encontrado!");
|
You are making a return without
paginaCarregada = true;
| Quote: | return;
}
if( !All )
{
FrameDoc->Release();
ShowMessage("ERRO!!! \'All\' não encontrado!");
|
You are making a return without
paginaCarregada = true;
| Quote: | return;
}
paginaCarregada = true;
}
else
{
paginaCarregada = false;
}
}
Any better ideas to do this?
|
Well you never told what you wanted to happen, nor explained the
start of the scenario.
| Quote: | I cannot put my code direct in BrowserDocumentComplete, for various
reasons....
|
Should we guess?
| Quote: | One is that I use this code:
int TjanelaPrincipal::Agendamento(void)
|
You did not tell where/when you call that function
| Quote: | {
IDispatch *pDisp;
IHTMLInputElement *pInput;
IHTMLSelectElement *pSelect;
IHTMLOptionElement *pOption;
TAGIntervalo *pIntervalo;
WideString opcao;
AnsiString qtde;
long pItens;
int i, m, d, h, qtde_n;
|
That looks like C programming. Why not declare the variables at the
moment where you first use them?
| Quote: | meses.Reiniciar();
datas.Reiniciar();
|
We do not see what that code does.
| Quote: | pSelect = SelectElement("mesDisponivel");
|
You did not explain that function nor the rest of the code.
You would be better off if you managed to produce a htmlpage
that you could put on the internet and that we could use too.
Hans. |
|
| Back to top |
|
 |
Eduardo Jauch Guest
|
Posted: Wed Feb 07, 2007 12:51 am Post subject: Re: TCPPWebBrowser SLOW for a certain time of day |
|
|
Hans Galema escreveu:
| Quote: | So TCppWebBRowser is slow, IE is slow and Firefox is fast.
|
Well... I think so.
| Quote: |
Was not my code I think, but anyway, I do this:
void TjanelaPrincipal::CarregarFrame(WideString url)
{
TVariant FrameName( "iContent" );
paginaCarregada = false;
Browser->Navigate( url, TNoParam(), &FrameName );
while( !paginaCarregada )
{
Application->ProcessMessages();
}
}
Is that code that loads a htmppage in one of the frames of an existing
page? Why didn't you tell?
|
Yes. I don't know.
| Quote: | What is the use of paginaCarregada ? I think you can omit it all the way.
And at least the loop with Application->ProcessMessages(); looks not
needed.
|
Without this, the OnDocumentComplete NEVER is fired... Because the
message NEVER come to my program (I tried...)
And if I don't use the looping, my code continues after "browse" the
page, and i get all wrong simple because the page is not yet completed
downloaded.
By the way, the code with the CurDispatch, i get on the BCB 6 help.
| Quote: |
void __fastcall TjanelaPrincipal::BrowserNavigateComplete2(TObject
*Sender,
LPDISPATCH pDisp, Variant *URL)
{
if (!CurDispatch)
CurDispatch = pDisp;
}
You did explain nothing of CurDispath? What is it? Where did you assign it?
Why this code?
|
Ok. paginaCarregada and CurDispatch are global variables.
Because the page have frames, i use CurDispatch to hold the pDisp value
guve by OnNavigateComplete2.
The OnNavigateComplete2 can occour before the entire page is loaded.
| Quote: |
void __fastcall TjanelaPrincipal::BrowserDocumentComplete(TObject
*Sender,
LPDISPATCH pDisp, Variant *URL)
{
if (pDisp == CurDispatch)
{
CurDispatch = NULL;
FrameDoc = Frame( WideString("iContent") );
You did not explain the function Frame().
|
Function Frame:
IHTMLDocument2 * TjanelaPrincipal::Frame(WideString nome)
{
if( !Browser->Document ) return NULL;
IHTMLDocument2 *Doc = NULL;
Browser->Document->QueryInterface( IID_IHTMLDocument2,(LPVOID*)&Doc );
if( !Doc ) return NULL;
IHTMLFramesCollection2 *Frames;
Doc->get_frames(&Frames);
Doc->Release();
if( !Frames ) return NULL;
TVariant IndexOrName = nome;
TVariant Frame_;
Frames->item(&IndexOrName, &Frame_);
Frames->Release();
IHTMLDocument2 *FrameDoc;
if( (V_VT(&Frame_) == VT_DISPATCH) && (V_DISPATCH(&Frame_) != NULL) )
{
IHTMLWindow2 *Window;
V_DISPATCH(&Frame_)->QueryInterface(IID_IHTMLWindow2,(LPVOID*)&Window);
if( !Window ) return NULL;
Window->get_document(&FrameDoc);
Window->Release();
}
else
return NULL;
return FrameDoc;
}
This functions return the IGTMLDocument2 of the Frame given the name of
the frame.
| Quote: |
if( FrameDoc )
FrameDoc->get_all( &All );
else
{
ShowMessage("ERRO!!! \'Frame\' não encontrado!");
You are making a return without
paginaCarregada = true;
return;
}
if( !All )
{
FrameDoc->Release();
ShowMessage("ERRO!!! \'All\' não encontrado!");
You are making a return without
paginaCarregada = true;
return;
}
paginaCarregada = true;
}
else
{
paginaCarregada = false;
}
}
|
For the these two coments, the only ansewr that i can give is that I
don't implemented code for error yet. So, if there a error when loading
FrameDoc or All, I show a message and restart the program...
It's very crude, but I'm in "testing" only.
| Quote: |
Any better ideas to do this?
Well you never told what you wanted to happen, nor explained the
start of the scenario.
|
Well... I load a page. Then, I find it's frame named 'iContent' and it
itens collection (All)
I do this ONLY if the page is complete loaded. I will explain why soon... ;)
Then, i start to load the frames that are loaded normally by clicking on
some link, In this page, there are a flash menu that does it, until i
load the page that contains the login info.
I load the info and continue, until get a specific page (It's necessary
enter a certain amount of data on forms before came to this specific
page. When i do this, i start a loop:
IHTMLInputElement *pInput;
int situacao;
do
{
/*
The first for, set check on all the check box on the actual page
*/
for( int i = 0; i < requerentes->Count; i++ )
{
pInput = InputElement( "requerenteAgendado[" + IntToStr(i) +
"].informacoesChecadas" );
if( !pInput )
{
ShowMessage( "ERRO. Verifique a página." );
iniciar_bt->Enabled = true;
return;
}
pInput->put_status(1);
pInput->Release();
}
//Goes to the next page
CarregarFrame( "javascript: forwardCalendario()" );
//Agendamento is the function I posted before
situacao = Agendamento();
switch( situacao )
{
case -1:
ShowMessage( "ERRO. Verifique a página." );
iniciar_bt->Enabled = true;
break;
case 1:
ShowMessage( "AGENDADO!!!!!!" );
break;
case 0:
CarregarFrame( "javascript: confirmarInformacoesDeVisto()" );
break;
}
}while( situacao == 0 );
Before you ask, pInputElement, pSelectElement, pOptionElement are
functions to retrieve the 'IHTMLInputElement *', and 'IHTMLSelectElement
*', 'IHTMLOptionElement *' given the name of the element. You can see
then on the Agendamento function too.
| Quote: |
I cannot put my code direct in BrowserDocumentComplete, for various
reasons....
Should we guess?
|
Oh, no! I can tell
Only did not think was necessary...
Anyway, if you look at Agendamento function again, you will notice that
I have a looping, within a looping within a looping...
My English is not so good, but what I mean is something like this:
for(...)
{
for(...)
{
for(...)
{
}
}
}
Each of the for are for looping through one combo box
(IHTMLSelectElement) on the page. When i find the element I need on the
first select, I call the javascript associated with the select and go to
the next for.
This deletes all of the elements, because theses javascripts load
another page.
I created meses and datas (two classes) to hold all the elements of the
first select (meses) and second select (datas)
This is make by calling the member function "datas.AdicionarData"
When i do that, internally, the object set what the elements are good
for me. Can get more than one, and this is important.
I'll explain Agendamento now:
//-------------------------------
//Get the first select (combo)
pSelect = SelectElement("mesDisponivel");
//Get the number of itens on the select
pSelect->get_length( &pItens );
//looping to get all the itens and pass to meses class
for( i = 1; i < pItens; i++ )
{
pOption = OptionElement( pSelect, i );
if( !pOption ) return -1;
pOption->get_text( &opcao );
pOption->Release();
meses.AdicionarData( opcao );
info_mm->Lines->Add( "MÊS: " + AnsiString(opcao) );
}
pSelect->Release();
//-------------------------------
//Looping to get the elements returned by the meses class
int prxMes;
int prxData;
//meses.MesesAptos -> Number of itens on first select that are good
for( m = 0; m < meses.MesesAptos; m++ )
{
//get the first select (combo).
//Do this, because whe find one element good, will call javascript
//and the variable will be reseted automatically by TCppWebBrowser
pSelect = SelectElement( "mesDisponivel" );
if( !pSelect ) return -1;
//get the NEXT good item
prxMes = meses.IndiceProximaData;
if( prxMes == -1 ) return 0;
//select the item on the first combo (select)
pSelect->put_selectedIndex( prxMes );
pSelect->Release();
//reset the datas class (does this for every item on the first
//combo)
datas.Reiniciar();
//call a javascript that refresh the pages, putting the values on
//the second combo.
CarregarFrame( "javascript: popularListaDiasDisponiveis()" );
//do the same before, but to datas and with second combo)
pSelect = SelectElement( "diaDisponivel" );
if( !pSelect ) return -1;
pSelect->get_length(&pItens);
for(i = 1; i < pItens; i++)
{
pOption = OptionElement( pSelect, i );
if( !pOption ) return -1;
pOption->get_text( &opcao );
pOption->Release();
datas.AdicionarData( opcao ); //save the date
info_mm->Lines->Add( " Data: " + AnsiString(opcao) );
}
pSelect->Release();
//Now, find the good itens on second combo
for( d = 0; d < datas.DatasAptas; d++)
{
pSelect = SelectElement( "diaDisponivel" );
if( !pSelect ) return -1;
prxData = datas.IndiceProximaData;
if( prxData == -1 ) break;
pSelect->put_selectedIndex( prxData );
pSelect->Release();
//Load the javascript that refresh the page, loadind elements on
//the third combo
CarregarFrame( "javascript: popularListaHorariosDisponiveis()" );
pSelect = SelectElement( "seqHorarioAgendamentoDisponivel" );
if( !pSelect ) return false;
pSelect->get_length( &pItens );
for( i = 1; i < pItens; i++ )
{
pOption = OptionElement( pSelect, i );
if( !pOption ) break;
pOption->get_text(&opcao);
pOption->Release();
if(opcao.Length() == 3
qtde = opcao.SubString(28, 2);
else
qtde = opcao.SubString(28, 1);
qtde_n = qtde.ToInt();
//requerents are other class i create to control.
//have information i use to fill the forms that I said before
if(qtde_n >= requerentes->Count)
{
pSelect->put_selectedIndex(i);
//if find a good item on the third combo, execute this java
CarregarFrame( "javascript: confirmarAgendamento()" );
//If the page is the same, then the item don't work,
pSelect = SelectElement( "seqHorarioAgendamentoDisponivel" );
if( pSelect )
{
i = 1;
//set i to 1, because if item has already "taken", it
//desapears of the list and i must begin again.
}
else
{
return 1; //Conseguiu AGENDAR
}
}
}
//if no able to kake a good item on the third combo,
//try the next on the second combo
pSelect->Release();
}
//if no able to kake a good item on the second combo,
//try the next on the first combo
}
return 0; //Acabou a lista
}
So, if i try to use the OnDocumentComplete to do somethink like this,
the things will go on very Difficult... Because I will call it within it.
I tried.
| Quote: | One is that I use this code:
int TjanelaPrincipal::Agendamento(void)
You did not tell where/when you call that function
See above |
| Quote: |
{
IDispatch *pDisp;
IHTMLInputElement *pInput;
IHTMLSelectElement *pSelect;
IHTMLOptionElement *pOption;
TAGIntervalo *pIntervalo;
WideString opcao;
AnsiString qtde;
long pItens;
int i, m, d, h, qtde_n;
That looks like C programming. Why not declare the variables at the
moment where you first use them?
|
Because I are an old C programing and like to do this way. Old habits...
| Quote: |
meses.Reiniciar();
datas.Reiniciar();
We do not see what that code does.
|
For not create and recreate these class every time i enter the
Agendamento function, i create this member function that reset the data
on them.
| Quote: |
pSelect = SelectElement("mesDisponivel");
You did not explain that function nor the rest of the code.
|
See above.
| Quote: |
Any ideas???
You would be better off if you managed to produce a htmlpage
that you could put on the internet and that we could use too.
Hans.
|
I can't do this, because the page has lots of javasript that i not
understand yet...
I'm trying to use NMHTTP (or Indy10 when I get to install sucessfuly it)
But for now, the program works... For litle periods... ;)
The code, on the way i put here, works.
But during the day, most of time, it's impossible to work... Because the
pages are loaded so slowly... |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|