Hello All,
I have a form with my component on it. The component uses Indy's IdTCPClient
and runs series of transactions in threads (not TIdThread but TThread). For
testing purposes I need to be able to see the results of communication
between my client and a TCP/IP server. When I run the following code on the
component level it all works fine:
//TTransactionManager is a non-visual component
procedure TTransactionManager.DisplayResponse(sResponse: String);
var
i : Integer;
begin
for i := 0 to Application.MainForm.ComponentCount - 1 do begin
if Application.MainForm.Components[i] is TMemo then begin
(Application.MainForm.Components[i] as TMemo).Lines.Add(sResponse);
break;
end;
end;
end;
But if I run it within a thread as:
// called from critical section
procedure TTransactionThread.DisplayResponse;
var
i : Integer;
begin
for i := 0 to Application.MainForm.ComponentCount - 1 do begin
if Application.MainForm.Components[i] is TMemo then begin
// slResponse is a private TStringList of a TThread and is loaded with
response strings
TMemo(Application.MainForm.Components[i]).Lines.Add(slResponse[slResponse.Co
unt - 1]);
break;
end;
end;
end;
then the control never comes back.
Through debugger I can see memo.lines.Add taking me to Windows unit and
saying farewell with the line:
function SendMessage; external user32 name 'SendMessageA';
I suspect it's something to do with the way I try to access form's controls
from a thread, but I don't know what could be wrong.
All/any suggestions are welcomed and appreciated.
Thank you,
Sergei Stenkov
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED]
with body of "unsubscribe delphi"
Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/