HyperText

General TRichView support forum. Please post your questions here
Post Reply
skydiablo
Posts: 16
Joined: Wed Feb 14, 2007 1:31 pm

HyperText

Post by skydiablo »

hi (sorry for my bad english)

how can i make an hypertext ? so i want add a URL to a RV and the URL should blue and underline and if i click it, the IE opend with the URL ?

to recognize the URL i have it already but how can i it click-able ?

greez & thx, sky...
Sergey Tkachenko
Site Admin
Posts: 17565
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

For URL insertion, see the demo http://www.trichview.com/forums/viewtopic.php?t=61
For URL detection on typing, see the demo Demos\Delphi\Assorted\Hypertext\URLs
(there is an advanced version of this demo - http://www.trichview.com/support/files/urls.zip , but itrequires TRichView v1.9.31 or newer)

Note that by default hypertext in editor works when user presses and holds Ctrl key. The last demo ( http://www.trichview.com/support/files/urls.zip ) shows how to implement hypertext on single click. But I personally think it's very inconvenient.
skydiablo
Posts: 16
Joined: Wed Feb 14, 2007 1:31 pm

Post by skydiablo »

hi..

in my oppinion , the hole richview is always scanned in URL´s. but i only want to add one line, which is right from the beginning (and not always the hole richview scann again.) the addition of items/hyperlink i still do not really understand. perhaps you can explain it to me!?

greez & thx, sky...
Sergey Tkachenko
Site Admin
Posts: 17565
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Do you want to insert hyperlink in the position of caret (as an editing operation)? Or do you want to generate document with hyperlinks?

The demo http://www.trichview.com/forums/viewtopic.php?t=61 allows making hyperlink from the selected text. Inserting new hyperlink is even simpler:

Code: Select all

var StyleNo: Integer;
      Text, Target: String;

Text := 'Click Here';
Target := 'http://www.trichview.com';

StyleNo := RichViewEdit1.CurTextStyleNo;
// GetHypertextStyleNo is from the demo
RichViewEdit1.CurTextStyleNo := GetHypertextStyleNo(StyleNo);
RichViewEdit1.InsertStringTag(Text, Integer(StrNew(PChar(Target))));
RichViewEdit1.CurTextStyleNo := StyleNo;
---

Update 2011-Oct-22: starting from TRichView 13.3, use Target instead of Integer(StrNew(PChar(Target)))
Last edited by Sergey Tkachenko on Sat Oct 22, 2011 7:04 pm, edited 1 time in total.
Sergey Tkachenko
Site Admin
Posts: 17565
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

As for the second demo, it has 2 different features:
- detecting all URLs on button click;
- detecting URL on typing (only typed text is converted to hyperlink, the whole document is not scanned)
Sergey Tkachenko
Site Admin
Posts: 17565
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Some basics.

In TRichView, documents consists of items. One item can be:
- picture, or control, or horizontal line, or other object;
- text without line break characters and without tabs, formatted with one text style;
- table (the most complex case, because table contains subdocuments (cells) consisting of their own items).

Items have different properties, for example tags (integer or string value for your own use). Tags can be used to store hypertext targets.
Any text item formatted with text style having Jump property = True is a hyperlink.

Additional information in the help file.
Post Reply