Thread View: borland.public.cppbuilder.internet.socket
4 messages
4 total messages
Started by David Ayre
Thu, 20 Jul 2006 13:04
Strange problem when using Indy 9 ftp/http
Author: David Ayre
Date: Thu, 20 Jul 2006 13:04
Date: Thu, 20 Jul 2006 13:04
54 lines
2380 bytes
2380 bytes
Hi,
I have at last got my application working using http component
and it works fine on my computer. However, I have discovered an
odd qhirk in its operation on other computers.
When I run the application, it brings up a form on which there are
TLabels onto which I put messages to say what is happening.
The application then downloads a file from my website. However,
what happens on other computers is that the form appears and
remains blank until I move the mouse pointer over it. Then it
springs into life.
Any idea what I have done wrong?
This is the relevant code:-
char acFile[256];
char acPath[256];
char acDest[256];
char acVersion[64];
char acIniFile[256];
GetPrivateProfileString("PATHS","DATA","s:\\mtdata",acPath,sizeof(acPath),".\\paths.ini");
Application->HandleMessage();
ListBox1->Clear();
sprintf(acIniFile,"%smtrader.ini",acPath);
GetPrivateProfileString("VERSION","NUMBER","000001",acVersion,sizeof(acVersion),acIniFile);
int iOldVersion = atoi(acVersion);
strcpy(acFile,"version.ini");
sprintf(acDest,"%s%s",acPath,acFile);
remove(acDest);
char acCaption[128];
sprintf(acCaption,"Downloading %s",acFile);
Label1->Caption = acCaption;
TFileStream *SL = new TFileStream(acDest,fmCreate);
try
{
try
{
IdHTTP1->Get("http://www.selectdata.co.uk/FML/version.ini",SL);
}
__finally
{
delete SL;
ListBox1->Items->Add("Checking Latest Version");
}
}
catch(const Exception &)
{
DeleteFile(acDest);
}
David
Re: Strange problem when using Indy 9 ftp/http
Author: Remy Lebeau (TeamB)
Date: Thu, 20 Jul 2006 15:52
Date: Thu, 20 Jul 2006 15:52
29 lines
1986 bytes
1986 bytes
"David Ayre" <davidcayre@ntlworld.com> wrote in message news:44bf7f5b$1@newsgroups.borland.com... > The application then downloads a file from my website. However, > what happens on other computers is that the form appears and > remains blank until I move the mouse pointer over it. Then it > springs into life. Indy is a blocking library. Since you are using it in the main thread, while it is downloading, the message queue cannot process new messages, including painting messages. Either drop a TIdAntiFreeze onto the form, or else call the form's Update() method in the TIdHTTP's OnWork events, or else move the TIdHTTP to a separate thread. > Application->HandleMessage(); You are processing only a single message, not all pending messages. Call ProcessMessages() instead of HandleMessage(). > sprintf(acCaption,"Downloading %s",acFile); > Label1->Caption = acCaption; Try calling the form's Update() method just before calling TIdHTTP::Get(). That will update the form's display just before TIdHTTP then blocks the message queue. Gambit
Re: Strange problem when using Indy 9 ftp/http
Author: David Ayre
Date: Thu, 20 Jul 2006 17:21
Date: Thu, 20 Jul 2006 17:21
45 lines
2448 bytes
2448 bytes
Thanks Remy, I'll have a look at those points. However, it does seem to stop before the http gets going. Just running the mouse pointer over the form sets it going. As to putting it in a separate thread. I haven't used threads. Could you give me a few pointers on how to do this, please. Cheers, David "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com> wrote: > >"David Ayre" <davidcayre@ntlworld.com> wrote in message >news:44bf7f5b$1@newsgroups.borland.com... > >> The application then downloads a file from my website. However, >> what happens on other computers is that the form appears and >> remains blank until I move the mouse pointer over it. Then it >> springs into life. > >Indy is a blocking library. Since you are using it in the main thread, >while it is downloading, the message queue cannot process new messages, >including painting messages. Either drop a TIdAntiFreeze onto the form, or >else call the form's Update() method in the TIdHTTP's OnWork events, or else >move the TIdHTTP to a separate thread. > >> Application->HandleMessage(); > >You are processing only a single message, not all pending messages. Call >ProcessMessages() instead of HandleMessage(). > >> sprintf(acCaption,"Downloading %s",acFile); >> Label1->Caption = acCaption; > >Try calling the form's Update() method just before calling TIdHTTP::Get(). >That will update the form's display just before TIdHTTP then blocks the >message queue. > > >Gambit > >
Re: Strange problem when using Indy 9 ftp/http
Author: David Ayre
Date: Fri, 21 Jul 2006 14:54
Date: Fri, 21 Jul 2006 14:54
57 lines
2654 bytes
2654 bytes
Thanks Remy, That seemed to get it working OK, but I'd still appreciate some pointers as to how to use Threads. Cheers, David "David Ayre" <davidcayre@ntlworld.com> wrote: > >Thanks Remy, > >I'll have a look at those points. However, it does seem to stop >before the http gets going. Just running the mouse pointer over the form sets it going. >As to putting it in a separate thread. I haven't used threads. >Could you give me a few pointers on how to do this, please. > >Cheers, > >David > > >"Remy Lebeau \(TeamB\)" <no.spam@no.spam.com> wrote: >> >>"David Ayre" <davidcayre@ntlworld.com> wrote in message >>news:44bf7f5b$1@newsgroups.borland.com... >> >>> The application then downloads a file from my website. However, >>> what happens on other computers is that the form appears and >>> remains blank until I move the mouse pointer over it. Then it >>> springs into life. >> >>Indy is a blocking library. Since you are using it in the main thread, >>while it is downloading, the message queue cannot process new messages, >>including painting messages. Either drop a TIdAntiFreeze onto the form, or >>else call the form's Update() method in the TIdHTTP's OnWork events, or else >>move the TIdHTTP to a separate thread. >> >>> Application->HandleMessage(); >> >>You are processing only a single message, not all pending messages. Call >>ProcessMessages() instead of HandleMessage(). >> >>> sprintf(acCaption,"Downloading %s",acFile); >>> Label1->Caption = acCaption; >> >>Try calling the form's Update() method just before calling TIdHTTP::Get(). >>That will update the form's display just before TIdHTTP then blocks the >>message queue. >> >> >>Gambit >> >> >
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads