|
TCustomRichView.OnWriteHyperlink |
Top Previous Next |
|
Occurs when RichView wants to save hypertext link to HTML or RTF file type TRVWriteHyperlink = procedure (Sender: TCustomRichView; id: Integer; RVData: TCustomRVData; ItemNo: Integer; SaveFormat: TRVSaveFormat; var Target, Extras: String) of object;
property OnWriteHyperlink: TRVWriteHyperlink; (introduced in v1.8) By default, hypertext links (associated with hypertext text styles, hotspots and hot-pictures) are not saved in HTML and RTF. But you can use this event to save them (or some of them). In order to do it, you need to assign Target parameter to the target URL.
Input parameters: id – identifier of the hypertext link; this event can be called for unformatted documents; in this case, id=-1. RVData – document containing hyperlink (Sender.RVData, or table cell, or cell inplace editor's RVData) ItemNo – index of hyperlink-item inside RVData. SaveFormat can be rvsfHTML or rvsfRTF.
Output parameters: Target – hyperlink target to save in file or stream Extras – optional additional information for saving with the link. When saving RTF files, if Target is started from '#', TRichView removes '#' from the target and add '\l' in Extras. Thus, such links are saved as links to bookmarks (checkpoints are saved as bookmarks) Example 1: The most typical using: URLs are saved in tags, and rvoTagsArePChars is in Options In addition to saving the link target, this example saves the hint "Click here!" (both for RTF and HTML) and the attribute "target=_blank" for HTML. procedure TMyForm.MyRichViewWriteHyperlink( Sender: TCustomRichView; id: Integer; RVData: TCustomRVData; ItemNo: Integer; SaveFormat: TRVSaveFormat; var Target, Extras: String); begin Target := PChar(RVData.GetItemTag(ItemNo)); case SaveFormat of rvsfHTML: Extras := 'target=_blank title="Click here!"'; rvsfRTF: Extras := '\o "Click here!"'; end; end; Saving hint is given here only as an example. TRichView saves hints stored in the rvespHint item's extra string property automatically.
Example 2: procedure TMyForm.MyRichViewWriteHyperlink( Sender: TCustomRichView; id: Integer; RVData: TCustomRVData; ItemNo: Integer; SaveFormat: TRVSaveFormat; var Target, Extras: String); begin case id-FirstJumpNo of 0: Target := 'http://www.borland.com'; 1: Target := 'http://www.inprise.com'; end; end;
See also events: See also methods:
See also: |