美文网首页
Delphi控件开发(一) TUrlLabel

Delphi控件开发(一) TUrlLabel

作者: 风语007 | 来源:发表于2016-11-18 19:38 被阅读0次
    unit UrlLabel;
    
    interface
    
    uses
      Windows, SysUtils, Messages, Classes, Controls, StdCtrls, ShellAPI, Graphics, Forms;
    
    type
      TUrlLabel = class(TLabel)
      private
        { Private declarations }
        FUrl: string;
        procedure SetUrl(const Value: string);
      protected
        { Protected declarations }
        procedure Click; override;
      public
        { Public declarations }
        constructor Create(AOwner: TComponent); override;
      published
        { Published declarations }
        property Url: string  read FUrl write SetUrl;
      end;
    
    procedure Register;
    
    implementation
    
    procedure Register;
    begin
      RegisterComponents('Samples', [TUrlLabel]);
    end;
    
    { TUrlLabel }
    
    procedure TUrlLabel.Click;
    begin
      ShellExecute(Application.Handle,nil,PChar(url),nil,nil,SW_NORMAL);
      inherited;
    end;
    
    constructor TUrlLabel.Create(AOwner: TComponent);
    begin
      inherited;
      Cursor := crHandPoint;
      Font.Style := [fsUnderline];
    end;
    
    procedure TUrlLabel.SetUrl(const Value: string);
    begin
      FUrl := Value;
    end;
    
    end.
    

    相关文章

      网友评论

          本文标题:Delphi控件开发(一) TUrlLabel

          本文链接:https://www.haomeiwen.com/subject/zjcjpttx.html