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

1

2

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}}}
Staciastacie answered 15/2, 2017 at 13:40 Comment(0)
C
3

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

Callimachus answered 16/2, 2017 at 12:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.