Hyperlink

General TRichView support forum. Please post your questions here
Post Reply
etwoss
Posts: 1
Joined: Sun Feb 16, 2020 8:22 am

Hyperlink

Post by etwoss »

Hi

Perhaps simple question: how can i, from Delphi code, insert a hyperlink like

a href="https://someurl">Visit W3Schools</a>

Into the RichEdit

Thanks for anwering

Eric

Sergey Tkachenko
Site Admin
Posts: 15166
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: Hyperlink

Post by Sergey Tkachenko »

I assume that your question is about our components (TRichViewEdit), not about the standard TRichEdit.

Do you use RichViewActions?

If yes, the simplest way is to use TrvActionInsertHyperlink:

Code: Select all

rve.CurTextStyleNo := rvActionInsertHyperlink1.GetHyperlinkStyleNo(rve);
rve.InsertStringTag('Visit W3Schools', 'https://someurl');
You need to process OnJump event to open the clicked link in browser (or perform other operation):

Code: Select all

procedure TForm3.rveJump(Sender: TObject; id: Integer);
begin
  rvActionInsertHyperlink1.GoToLink(rve, id);
end;
If you do not use RichViewActions, it would require more code (to specify hyperlink attributes), see the demo in <TRichView Dir>\TRichView\Demos\DelphiUnicode\Assorted\Hypertext\CreateHyperlink\

Post Reply