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.
网友评论