为什么TIdTextEncoding.Default未声明?

时间:2015-02-16 15:18:17

标签: delphi indy

我尝试构建我从http://sourceforge.net/projects/indy10clieservr/获得的第一个客户端项目,但它表示来自第62行的TIdTextEncoding和Default都是未声明的。我没有任何机会,那么是什么导致了这个?

完整代码:     接口

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient, IdGlobal;

type
  TClientForm = class(TForm)
    CheckBoxConnectDisconnet: TCheckBox;
    ButtonSendString: TButton;
    Edit1: TEdit;
    Memo1: TMemo;
    IdTCPClient1: TIdTCPClient;
    procedure CheckBoxConnectDisconnetClick(Sender: TObject);
    procedure ButtonSendStringClick(Sender: TObject);
    procedure IdTCPClient1Connected(Sender: TObject);
    procedure IdTCPClient1Disconnected(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  ClientForm: TClientForm;

implementation

{$R *.dfm}

{ TForm1 }

procedure TClientForm.ButtonSendStringClick(Sender: TObject);
var
  LLine: String;
begin

  IdTCPClient1.IOHandler.WriteLn(Edit1.Text, TIdTextEncoding.Default);
  Edit1.Text := '';
  LLine := IdTCPClient1.IOHandler.ReadLn();
  if ( LLine = 'OK' ) then
      Memo1.Lines.Add('Server says it has received your String');

end;

procedure TClientForm.CheckBoxConnectDisconnetClick(Sender: TObject);
begin
  if ( CheckBoxConnectDisconnet.Checked = True ) then
  begin
    IdTCPClient1.Host := '127.0.0.1';
    IdTCPClient1.Port := 6000;
    IdTCPClient1.Connect;
  end
  else
    IdTCPClient1.Disconnect;
end;

procedure TClientForm.IdTCPClient1Connected(Sender: TObject);
begin
  Memo1.Lines.Add('Client connected with server');
end;

procedure TClientForm.IdTCPClient1Disconnected(Sender: TObject);
begin
  Memo1.Lines.Add('Client disconnected from server');
end;

end.

1 个答案:

答案 0 :(得分:9)

这个项目在sourceforge主页上只列出了Delphi 2010,XE和XE2,所以我猜它还没有更新到更新的Indy版本。

在Indy 10.6中删除了

TIdTextEncoding,如Indy ChangeLog blog中所述:

Indy 10.6 has been released

  

IdGlobal.TIdTextEncoding类已被替换为新的IdGlobal.IIdTextEncoding refcounted接口,该接口不再依赖于SysUtils.TEncoding(Embarcadero)或System.Text.Encoding(.NET)(尽管如果您仍然提供了包装器需要与Indy一起使用)。因此,不推荐使用IndyXXXEncoding()函数来支持新的IndyTextEncoding_XXX()函数。

Indy 10.6引入了一个新的IndyTextEncoding_OSDefault()函数作为TIdTextEncoding.Default的替代品。 (见here