delphi 中未声明的标识符 "idhttp1"

undeclared identifier "idhttp1" in delphi

我正在尝试从 Delphi 2010 年的 URL 加载图像。

我是 Delphi 的新手,找到了这段代码,但不断收到:

undeclared identifier at idhttp1.get

我需要在用途上添加一些东西吗?谢谢

uses
  GIFImg;

procedure TForm1.btn1Click(Sender: TObject);
var
  MS : TMemoryStream;
  GIf: TGIFImage;
begin
  MS := TMemoryStream.Create;
  GIf := TGIFImage.Create;
  try
    IdHTTP1.get('http://www.google.com/intl/en_ALL/images/logo.gif',MS);
    Ms.Seek(0,soFromBeginning);       
    Gif.LoadFromStream(MS);
    img1.Picture.Assign(GIF);

  finally
    FreeAndNil(GIF);
    FreeAndNil(MS);
  end;
end;

用法表明 IdHTTP1 是一个类型为 TIdHTTP 的组件,它放置在表单的设计图面上。这可能是您错过的步骤。执行该步骤后,代码应该可以编译。