unit
Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, IdBaseComponent, IdComponent, IdTCPConnection,
IdTCPClient, IdHTTP;
type
TGoThread =
class
(TThread)
private
FURL:
String
;
FMemo: TMemo;
FRes:
String
;
procedure
Updt;
protected
procedure
Execute; override;
public
constructor
Create(AURL:
String
; AMemo: TMemo);
end
;
TForm1 =
class
(TForm)
Memo1: TMemo;
Memo2: TMemo;
Memo3: TMemo;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Button1: TButton;
procedure
Button1Click(Sender: TObject);
private
public
end
;
var
Form1: TForm1;
implementation
{$R *.dfm}
constructor
TGoThread
.
Create(AURL:
String
; AMemo: TMemo);
begin
inherited
Create(
True
);
FURL:=AURL;
FMemo:=AMemo;
FRes:=
''
;
Resume;
end
;
procedure
TGoThread
.
Execute;
var
IdHTTP: TIdHTTP;
begin
IdHTTP:=TIdHTTP
.
Create(Form1);
try
try
FRes:=IdHTTP
.
Get(FURL);
except
FRes:=
'Exception: '
+Exception(ExceptObject).Message;
end
;
Synchronize(Updt);
finally
IdHTTP
.
Free;
end
;
end
;
procedure
TGoThread
.
Updt;
begin
FMemo
.
Text:=FRes;
end
;
procedure
TForm1
.
Button1Click(Sender: TObject);
begin
TGoThread
.
Create(Edit1
.
Text, Memo1);
TGoThread
.
Create(Edit2
.
Text, Memo2);
TGoThread
.
Create(Edit3
.
Text, Memo3);
end
;
end
.