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.
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.
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;
It depends on what you require of your hyperlinks. I'd just...
What version of Delphi are you using? Looking at my Delphi 4 IDE, TLabel has no OnMouseEnter/OnMouseLeave event, which would be necessary to change the cursor to a "Hand" when the user hovers over the "link".
It does have the OnClick event, which you can wire up to launch the user's web browser:
http://stackoverflow.com/questions/1108075/how-to-bring-front-or-launch-browser-in-delphi
One can tab to and give focus to links in a browser. Therefore I would consider using a windowed control (like an owner-drawn TButton) for this task.