gpt4 book ai didi

inno-setup - 如何向自定义 Inno Setup WelcomeLabel 添加可点击链接?

转载 作者:行者123 更新时间:2023-12-02 20:25:36 26 4
gpt4 key购买 nike

我有一个带有自定义 WelcomeLabel2 消息的 Inno Setup 程序。

[Messages]
WelcomeLabel2=Lorem ipsum dolor sit amet CLICK_HERE consectetur adipiscing elit.

我正在尝试将 CLICK_HERE 设为可点击的网站链接。

我想知道的另一件事是如何使此 CLICK_HERE 文本粗体

我怎样才能实现这个目标?

最佳答案

这并不容易。

要创建一个整体可点击的标签,您可以使用如下代码:

procedure OpenBrowser(Url: string);
var
ErrorCode: Integer;
begin
ShellExec('open', Url, '', '', SW_SHOWNORMAL, ewNoWait, ErrorCode);
end;

procedure LinkClick(Sender: TObject);
begin
OpenBrowser('https://www.example.com/');
end;

procedure InitializeWizard;
var
Link: TLabel;
begin
Link := TLabel.Create(WizardForm);
Link.Left := ???;
Link.Top := ???;
Link.Parent := WizardForm.WelcomePage;
Link.Caption := 'CLICK_HERE';
Link.OnClick := @LinkClick;
Link.ParentFont := True;
Link.Font.Style := Link.Font.Style + [fsUnderline, fsBold];
Link.Font.Color := clBlue;
Link.Cursor := crHand;
end;

另请参阅Show License Agreement link in Inno Setup while installation .

<小时/>

尽管创建一个只有部分文本可点击的标签要困难得多。如果文本适合一行,则可以通过将三个标签彼此相邻堆叠(首先是前导静态文本,然后是链接,然后是尾随静态文本)来实现。但是,如果文本无法容纳在一行中,则这是不可行的,因为标签会相互重叠。

<小时/>

或者,您可以创建带有链接的 RTF 文档,并使用只读 TRichEditViewer 来呈现它:

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

为此,您需要 Unicode 版本(从 Inno Setup 6 开始的唯一版本),请参阅 How to add clickable links to custom page in Inno Setup using RichEditViewer?

要更改链接颜色,请参阅 Inno Setup - How to change the color of the hyperlink in RTF text?

<小时/>

正如 @Bill_Stewart 评论的那样,您应该避免以提升的权限启动浏览器。如需解决方案,请参阅How to open a web site after uninstallation in non-elevated mode?

关于inno-setup - 如何向自定义 Inno Setup WelcomeLabel 添加可点击链接?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37154573/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com