unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient,
IdFTP, StdCtrls;
type
TconnThread = class (TThread)
//继承自TThread类
private
procedure conn;
protected
procedure Execute;override;
end;
type
TForm1 = class(TForm)
IdFTP1: TIdFTP;
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure IdFTP1Status(ASender: TObject; const AStatus: TIdStatus;
const AStatusText: String);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
{TConnThread}
procedure TConnThread.conn;
begin
Form1.IdFTP1.Connect(True,5000);
end;
procedure TconnThread.Execute;
begin
inherited;
conn;
end;
procedure TForm1.Button1Click(Sender: TObject);
var connthread: TconnThread;
begin
connthread:=TconnThread.Create(False);
connthread.FreeOnTerminate:=true;
end;
procedure TForm1.IdFTP1Status(ASender: TObject; const AStatus: TIdStatus;
const AStatusText: String);
begin
Self.Caption:=AStatusText;
end;
end.