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

Inno Setup:如何根据Pascal条件修改SelectDirLabel3文本

实现动态修改「Select Destination Location」页面的SelectDirLabel3文本

可行方案:利用CurPageChanged事件动态修改控件文本

因为你需要根据Pascal代码中的条件动态调整文本,最直接的方式是在页面切换到目标文件夹选择页时,找到对应控件并修改其内容:

  • 在脚本的[Code]段中定义CurPageChanged事件处理函数,该函数会在页面切换时触发
  • 通过WizardForm.SelectDirPage获取目标文件夹页面的窗体对象
  • 使用FindComponent方法定位到SelectDirLabel3控件,检查控件存在后修改其Caption属性

代码示例

[Code]
procedure CurPageChanged(CurPageID: Integer);
var
  TargetLabel: TNewStaticText;
begin
  // 当切换到目标文件夹选择页时执行
  if CurPageID = wpSelectDir then
  begin
    // 定位SelectDirLabel3控件
    TargetLabel := TNewStaticText(WizardForm.SelectDirPage.FindComponent('SelectDirLabel3'));
    // 确保控件存在后修改文本
    if Assigned(TargetLabel) then
    begin
      // 这里替换成你需要的动态文本,可结合代码中的条件判断
      if 你的条件判断 then
        TargetLabel.Caption := '满足条件时的自定义文本'
      else
        TargetLabel.Caption := '默认自定义文本';
    end;
  end;
end;

补充说明

如果只是静态修改文本(无需根据代码条件),可以直接在脚本的[Messages]段中添加:

[Messages]
SelectDirLabel3=你的静态自定义文本

内容的提问来源于stack exchange,提问作者Hannes Schmid

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.20 08:24:14