Delphi User's Guide > Hypertext Links
In this first sample program a hypertext link will be inserted in a text document. The document is saved then as a HTML file so that it can be viewed in a browser.
Hypertext links are handled as a special type of a marked text field. A hypertext link therefore is inserted by calling the FieldInsert method, and then specifying the type of the field with the FieldType property:
TXTextControl1.FieldInsert ('Text Control Web Site'); TXTextControl1.FieldType[TXTextControl1.FieldCurrent] := txFieldExternalLink;
To store the target to where the link points, the FieldTypeData property is used:
TXTextControl1.FieldTypeData[TXTextControl1.FieldCurrent] := 'http://www.textcontrol.com';
The following line of code saves the document, containing the hypertext link, which has just been inserted as a HTML file in the sample folder:
TXTextControl1.Save (Application.GetNamePath + '.html', 0, 4, False);
When this file is loaded with a web browser, the hypertext link will be displayed as specified in your browser's settings. Clicking on the link, will take you to the Text Control web site.
Note that there is no code for the Click events yet, so clicking on the hypertext link in the Text Control will have no effect. Also, the link is neither underlined nor colored.