Inno Setup - 如何更改RTF文本中超链接的颜色?

时间:2017-02-15 13:40:20

标签: hyperlink inno-setup rtf

我使用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;

我想将超链接的颜色更改为蓝色:

enter image description here

如何使用上述代码使用answer by Oliver Bock to What is the RTF syntax for a hyperlink?更改RTF中更改超链接颜色的语法?

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

1 个答案:

答案 0 :(得分:2)

实际上,在Windows 7上,默认情况下链接颜色不是蓝色(在Windows 10上)。

强制某种链接颜色的正确RTF语法如下:

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