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

Rowan picture Rowan · Aug 25, 2009 · Viewed 13k times · Source

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.

Answer

DmitryK picture DmitryK · Aug 25, 2009

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;