hyperlinkinno-setuprtf

How to change the color of the hyperlink in RTF text in Inno Setup


I'm using code from How to add clickable links to custom Inno Setup WelcomeLabel?:

procedure InitializeWizard;
var
  RichViewer: TRichEditViewer;
begin
  RichViewer := TRichEditViewer.Create(WizardForm);
  RichViewer.Left := WizardForm.WelcomeLabel2.Left;
  RichViewer.Top := WizardForm.WelcomeLabel2.Top;
  RichViewer.Width := WizardForm.WelcomeLabel2.Width;
  RichViewer.Height := WizardForm.WelcomeLabel2.Height;
  RichViewer.Parent := WizardForm.WelcomeLabel2.Parent;
  RichViewer.BorderStyle := bsNone;
  RichViewer.TabStop := False;
  RichViewer.ReadOnly := True;
  WizardForm.WelcomeLabel2.Visible := False;

  RichViewer.RTFText :=
    '{\rtf1 Lorem ipsum dolor sit amet ' +
    '{\b {\field{\*\fldinst{HYPERLINK "https://www.example.com/" }}' +
    '{\fldrslt{CLICK_HERE}}}} ' +
    'consectetur adipiscing elit.}';
end;

And I want to change the color of the hyperlink to blue:

enter image description here

How do I use a syntax for changing changing hyperlink color in RTF from the answer by Oliver Bock to What is the RTF syntax for a hyperlink? with the above code?

{\colortbl ;\red0\green0\blue238;}
{\field{\*\fldinst HYPERLINK "URL"}{\fldrslt{\ul\cf1Text to display}}}

Solution

  • Indeed, on Windows 7, the link color is not blue by default (it is on Windows 10).

    The correct RTF syntax to force a certain link color is like:

    RichViewer.RTFText :=
      '{\rtf1 ' +
      '{\colortbl ;\red238\green0\blue0;}' +
      'Lorem ipsum dolor sit amet ' +
      '{\b {\field{\*\fldinst{HYPERLINK "https://www.example.com/" }}' + 
      '{\fldrslt{\cf1 CLICK_HERE\cf0 }}}} ' +
      'consectetur adipiscing elit.}';
    

    Red link on Windows 7

    Red link on Windows 10