You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Inno Setup安装向导左下角添加带链接的按钮/图片?

Inno Setup向导左下角添加带链接的按钮方案

要实现类似Inno Setup官方向导左下角的可点击链接按钮,你可以结合自定义控件定位和链接跳转逻辑来完成,不需要局限于单一位图方案。以下是具体实现步骤:

核心思路

  • 在向导窗口的左下角区域添加自定义可点击控件(带样式的按钮)
  • 为控件绑定点击事件,调用系统浏览器打开目标链接
  • 调整控件样式、位置,匹配官方向导的视觉风格

完整代码实现

[Setup]
AppName=MyApp
AppVersion=1.0
DefaultDirName={autopf}\MyApp
WizardStyle=modern

[Code]
procedure ShellExecute(hwnd: HWND; lpOperation: string; lpFile: string; lpParameters: string; lpDirectory: string; nShowCmd: Integer);
  external 'ShellExecuteW@shell32.dll stdcall';

procedure DonateClick(Sender: TObject);
begin
  // 替换为你的捐赠链接
  ShellExecute(0, 'open', '你的捐赠链接地址', '', '', 1);
end;

procedure GitHubClick(Sender: TObject);
begin
  // 替换为你的GitHub仓库链接
  ShellExecute(0, 'open', '你的GitHub仓库地址', '', '', 1);
end;

procedure InitializeWizard();
var
  DonateBtn: TButton;
  GitHubBtn: TButton;
  WizardHeight: Integer;
begin
  WizardHeight := WizardForm.Height;

  // 创建捐赠按钮
  DonateBtn := TButton.Create(WizardForm);
  DonateBtn.Parent := WizardForm;
  DonateBtn.Caption := '捐赠支持';
  DonateBtn.Left := 16;
  DonateBtn.Top := WizardHeight - 64;
  DonateBtn.Width := 80;
  DonateBtn.Height := 24;
  DonateBtn.OnClick := @DonateClick;
  DonateBtn.Flat := True;
  DonateBtn.Cursor := crHandPoint;

  // 创建GitHub按钮
  GitHubBtn := TButton.Create(WizardForm);
  GitHubBtn.Parent := WizardForm;
  GitHubBtn.Caption := '访问GitHub';
  GitHubBtn.Left := DonateBtn.Left + DonateBtn.Width + 8;
  GitHubBtn.Top := DonateBtn.Top;
  GitHubBtn.Width := 90;
  GitHubBtn.Height := 24;
  GitHubBtn.OnClick := @GitHubClick;
  GitHubBtn.Flat := True;
  GitHubBtn.Cursor := crHandPoint;
end;

procedure CurPageChanged(CurPageID: Integer);
begin
  // 适配窗口大小变化,保持按钮在左下角
  DonateBtn.Top := WizardForm.Height - 64;
  GitHubBtn.Top := WizardForm.Height - 64;
end;

说明

  • 用TButton创建可点击按钮,设置Flat=True模拟官方链接按钮的扁平化风格
  • 通过ShellExecute调用系统浏览器打开外部链接,保证跨系统兼容性
  • CurPageChanged事件处理窗口缩放后的位置调整,避免控件错位
  • 可根据需求修改按钮的文字、尺寸、位置,也可以通过Glyph属性为按钮添加图标

内容的提问来源于stack exchange,提问作者Lilith Helsente

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.16 04:01:06