如何在delphi中加超链接,使它能打开浏览器,浏览网页?

解决方案 »

  1.   

    可以在onclick事件中打开一个浏览器呀
    那个函数是什么我忘了
    你查一下,挺好找的
      

  2.   

    SellExecute(handle,nil,pchar('http://www.myvc.net'),nil,nil, 
                 sw_shownormal);
      

  3.   

    use shellapi;
    shellexecute(0,'open','www.csdn.net',nil,nil,sw_normal);
      

  4.   

    shellexecute(Application.handle,nil,pchar('http://www.sohu.com'),nil,nil,SW_SHOWNORMAL);
      

  5.   

    送一个带链功能的label控件unit UrlLabel;interfaceuses
      Windows, Classes, Controls, StdCtrls, SysUtils, Forms,
      Graphics, ShellAPI;type
      TUrlLabel = class(TLabel)  private
        { Private declarations }
        Url:string;
        procedure ExeUrl;
        procedure seturl(value:string);
      protected
        procedure Click;override;
      public
        { Public declarations }
        constructor Create(AOwner:TComponent);override;
      Published
        property UrlString:string read Url write seturl;
      end;procedure Register;implementationconst
      defaulturl:string='http://lb001.51.net';
    procedure TUrlLabel.click;
    begin
      inherited click;
      ExeUrl;
    end;
    constructor TUrlLabel.Create(AOwner:TComponent);
    begin
      inherited Create(AOwner);
      Url:=defaulturl;
      Caption:=Url;
      font.style:=[fsUnderline];
      font.color:=clBlue;
      Cursor:=crHandPoint;
    end;
    procedure TUrlLabel.ExeUrl;
    begin
      shellexecute(Application.handle,nil,pchar(Url),nil,nil,SW_SHOWNORMAL);
    end;
    procedure TUrlLabel.seturl(value:string);
    begin
      Url:=value;
      if csDesigning in ComponentState then
      begin
        Caption := Value;
        //Application.MessageBox('Your changed the urlstring!','',mb_ok); 
      end;
    end;procedure Register;
    begin
      RegisterComponents('mycontrols',[TUrlLabel]);
    end;end.
      

  6.   

    在use 中加shellapi
    再在label1的ONCLICK事件中加入
    SellExecute(handle,nil,'http://www.whlhbh.8u8.com',nil,nil, 
                 sw_shownormal);
    如果想做更像的话可以定义LABEL1的鼠标形状定义成手形,在ONMOUSEMOVE
    事件中使LABEL1的字变色。
      

  7.   

    uses ShellAPI;
    SellExecute(handle,nil,pchar('http://www.163.com'),nil,nil, 
                 sw_shownormal);
      

  8.   

    邮件连接一样
    uses ShellApi
    shellexecute(handle,nil,pchar('mailto:[email protected]'),nil,nil,sw_shownormal);