Re: Textstyle of Hyperlinks

Return to index



Sergey Tkachenko

Posted: 09/22/2004 19:05:43


TRichView treats hyperlinks like normal text. They are not underlined by

default, they do not have special colors. It's up to you to define

attributes for distinguishing hyperlinks from normal text.

Hyperlink attributes can be changed exactly like attributes of normal text

(note: there are some attributes present for all text styles, but used only

for hyperlinks -HoverColor and HoverBackColor).

Some ideas:

1) Yes, you can use different text styles to insert different links. But

user can apply different style (or style conversion procedure), so

hyperlink's style will be changed.

Do you use RichViewActions? If not, you have full control over operations

performed in OnStyleConversion event. You can block modification of

ununderlining or color changing for hyperlinks.

1) You can use OnApplyStyle and OnDrawStyleText to modify hyperlink


Only in OnDrawStyleText you can get link's target, so, if you want

target-depending drawing, you are limited with color changing and



- all hyperlinks are underlined regardless of their character attributes

- hyperlinks with empty target has light gray background

- links to e-mails are blue, to urls are green, others are gray.

procedure TForm3.RVStyle1DrawStyleText(Sender: TRVStyle; const s: String;

  Canvas: TCanvas; StyleNo, SpaceBefore, Left, Top, Width, Height: Integer;

  DrawState: TRVTextDrawStates; var DoDefault: Boolean);

var target: String;


  if Sender.TextStyles[StyleNo].Jump then begin

    Canvas.Font.Style := Canvas.Font.Style+[fsUnderline];

    if rvtsSelected in DrawState then


    target := PChar(TCustomRVData(Sender.RVData).GetItemTag(Sender.ItemNo));

    if target='' then begin

      Canvas.Brush.Color := clSilver;



    if RVIsEmail(target) then

      Canvas.Font.Color := clBlue

    else if RVIsURL(target) then

      Canvas.Font.Color := clGreen


      Canvas.Font.Color := clGray;



The only problem with this method - these color/underline changes will not

be saved in HTML/RTF.

> Hello,

> I have a question about how to influence the text style of a hyperlink.


> when inserting a hyperlink, the text will be blue and underlined.

> If I would like to change this style, how would I do this?


> Second question: If I would like to have a different style depending on,

> for example, if the hyperlink target is a URL or an Email address, is this

> also possible?


> Thanks for your help!

>  Holger

Powered by ABC Amber Outlook Express Converter