如:www.123.com/pic/1.jpg,把这个图片在一上网时就显示在form的image控件上。或者用其他控件,
请问如何实现呢?谢谢。

解决方案 »

  1.   

    不用image,可以用TWebBrowser或TIdHttp控件。
      

  2.   

    以下的程序可以把URL指定的网站上的图片down下来保存为'c:\aaa.jpg',接下来显示的问题估计不难了。
    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls, DB, Grids, DBGrids, DBTables, IdBaseComponent,
      IdComponent, IdTCPConnection, IdTCPClient, IdHTTP, ExtCtrls;type
      TForm1 = class(TForm)
        Button1: TButton;
        Edit1: TEdit;
        Image1: TImage;
        IdHTTP: TIdHTTP;
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}const  JPG_FILE = 'c:\aaa.jpg';procedure TForm1.Button1Click(Sender: TObject);
    var
      f : TFileStream;
    begin
      f := TFileStream.Create(JPG_FILE,fmCreate);
      idhttp.Get('http://ad4.sina.com.cn/200501/07/9132.JPG',f);
      f.Free;
    end;end.
      

  3.   

    我来把楼上的代码补充完整吧
    -------------------------------------------------  
    procedure TForm1.Button1Click(Sender: TObject);
    var
      f : TFileStream;
    begin
      f := TFileStream.Create(JPG_FILE,fmCreate);
      idhttp.Get('http://ad4.sina.com.cn/200501/07/9132.JPG',f);
      f.Position := 0;
      Image1.Picture.Bitmap.LoadFromStream(f);//自己加Image1
      f.Free;
    end;
      

  4.   

    楼上的老兄啊,TImage是不可以动态加载jpg文件的
      

  5.   

    不好意思
    我写代码的时候用的是bmp
    所以就写上去了
      

  6.   

    var
      LStream: TStream;
      Ljpg: TJpegImage;
    begin
      try
        LStream := TMemoryStream.Create;
        IdHttp1.Get(Edit1.Text, LStream);
        LStream.Position := 0;
        Ljpg := TJpegImage.Create;
        Ljpg.LoadFromStream(LStream);
        Image1.Picture.Assign(Ljpg);
      finally
        if LStream <> nil then LStream.Free;
        if Ljpg <> nil then Ljpg.Free;
      end;
    end;