请问我如何在一个窗体中不用按钮而用一个超级连接的样式来打开一个对话框

解决方案 »

  1.   

    一个带链功能的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.
      

  2.   

    procedure TLabel1.click(******);
    begin
      Showmessage('you click me !');
    end;
      

  3.   

    JennyVenus() :你这个组件能打开对话框吗?怎么用?goldencity(响马) :没明白你什么意思哦:(
      

  4.   

    在form上放一个label1//超级连接效果
    procedure TForm1.Label1MouseMove(Sender: TObject; Shift: TShiftState; X,
            Y: Integer);
    begin
    label1.Font.Style:=[fsbold,fsunderline];
    label1.font.color:=clyellow;
    end;
    procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
            Y: Integer);
    begin
    label1.Font.Style:=[fsbold];
    label1.font.color:=clmaroon;
    end;
    //打开连接
    use shellapi;procedure TForm1.Label1Click(Sender: TObject);
    begin
      ShellExecute(handle,'open','Explorer',pChar('http://www.csdn.net'),nil,SW_SHOW);
    end;