delphihyperlinktlabel

How do I make a TLabel behave like a hyperlink in Delphi?


How do I make a TLabel behave like a hyperlink in Delphi?

Note: I'm not interested in using TLinkLabel because of backwards compatibility issues.


Solution

  • Colour it blue, set style to underline and add an OnClick event!

    procedure TForm1.Label1Click(Sender: TObject);
    var
      MyLink: string;
    begin
      MyLink := 'http://www.mysite.com/';
      ShellExecute(Application.Handle, PChar('open'), PChar(MyLink),    
       nil, nil, SW_SHOW);
    end;