function getUrlSource(strUrl: string):string;   //获取网页源码
begin            //try
            lsResult := IdHTTP1.GET(strUrl);            //except
                //ShowMessage('获取源码出错');
            //end;end;
错误提示:IdHTTP1没定义!页面上已加入TIdHTTP控件。

解决方案 »

  1.   

    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls;type
      TForm1 = class(TForm)
        Button1: TButton;
      private
        { Private declarations }
      public
        { Public declarations }
        function getUrlSource(strUrl: string):string;
      end;var
      Form1: TForm1;implementation{$R *.dfm}function TForm1.getUrlSource(strUrl: string): string;
    begin
      //try
                lsResult := IdHTTP1.GET(strUrl);            //except
                    //ShowMessage('获取源码出错');
                //end;
    end;
      

  2.   

    也许名字不叫“IdHTTP1”;
    也许你没有uses含有IdHTTP1的unit
      

  3.   

    form1的方法才能这样使用
    独立函数,需要指明控件是那个form里的
      

  4.   

    楼主的getUrlSource,看样子不是TForm的成员函数,当访问窗体组件时,需要指明组件的所属或者把getUrlSource作为TForm的成员函数,那样就可以了