Page 1 of 1

HyperText

Posted: Wed Mar 14, 2007 6:20 pm
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...

Posted: Thu Mar 15, 2007 8:18 pm
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.

Posted: Thu Mar 15, 2007 10:18 pm
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...

Posted: Fri Mar 16, 2007 7:23 am
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)))

Posted: Fri Mar 16, 2007 7:25 am
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)

Posted: Fri Mar 16, 2007 7:35 am
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.