首页 > 解决方案 > Inno Setup 向页面添加描述文本

问题描述

我在理解如何使用 Inno Setup 时遇到了一些问题。我创建了这个脚本来安装我的应用程序:

; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

#define MyAppName "MyApp"
#define MyAppVersion "1.0"
#define MyAppPublisher "Myself"
#define MyAppExeName "MyApp.exe"

[Setup]
; NOTE: The value of AppId uniquely identifies this application.
; Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{5FA0A2CF-7FD4-4464-AF88-4B73D0857D03}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
DefaultDirName=C:\{#MyAppName}
DisableDirPage=no
DefaultGroupName=MyApp
;DisableProgramGroupPage=yes
OutputDir=D:\test
OutputBaseFilename=MyApp
Compression=lzma
SolidCompression=yes
PrivilegesRequired=lowest
UninstallDisplayName=MyApp {#MyAppName}
SetupIconFile="D:\MyApp\MyApp.ico"

[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"

[Files]
Source: "D:\MyApp\MyApp.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "D:\MyApp\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
; NOTE: Don't use "Flags: ignoreversion" on any shared system files

[CustomMessages]
FileTemplateDescription=Test description

[Code]
var
  DataDirPage: TInputDirWizardPage;
  FileTemplatePage: TInputQueryWizardPage;
  CustomStatusLabel: TNewStaticText;

procedure InitializeWizard;
begin
  { This part creates the page where to choose the data location directory }
  DataDirPage := CreateInputDirPage(wpSelectDir,
    'Select data directory', 'Where are the files you want to use?',
    'Select the folder where the data files are located, then click Next.',
    False, '');
  DataDirPage.Add('');

  DataDirPage.Values[0] := GetPreviousData('DataDir', '');

  { This part creates the page where to add the filetemplate }
  FileTemplatePage := CreateInputQueryPage(DataDirPage.ID,
    'File template', 'This is an advance option, do not change it if you are not sure.',
    'Please specify the file template, then click Next.');

  // Add items (False means it's not a password edit)
  FileTemplatePage.Add('File template:', False);

  // Set initial values (optional)
  FileTemplatePage.Values[0] := 'GlobalStatReanalysis_temp_sal_ssh_u_v_{{dateTime:%Y%m%d}.nc';

  // Description of the file template
  //  FileTemplatePage.Description := 'Test of description.';
  { S := CustomMessage('FileTemplateDescription');}
    CustomStatusLabel := TNewStaticText.Create(WizardForm);
  CustomStatusLabel.Parent := WizardForm.InstallingPage;
  CustomStatusLabel.Caption := 'Test Text';

end;

//procedure CurPageChanged(CurPageID: Integer);
  //begin
//    M:= TLabel.Create(WizardForm);
    //M.Caption:= (ExpandConstant('{cm:FileTemplateDescription}'));
  //end;

function GetDataDir(Param: String): String;
begin
  { Return the selected DataDir }
  Result := DataDirPage.Values[0];
end;

function GetFileTemplate(Param: String): String;
begin
  // Return values into variables
  Result := FileTemplatePage.Values[0];
end;

[Icons]
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; IconFilename: "{app}\MyApp.ico"; Parameters: "--path:{code:GetDataDir} --filetemplate:{code:GetFileTemplate} --fileconfig:""{app}\conf.yml"""

[Run]
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent; Parameters: "--path:{code:GetFileTemplate} --filetemplate:{code:GetDataDir} --fileconfig:""{app}\conf.yml"""

我创建了页面FileTemplatePage,以便用户可以添加文件模板。我想要的是在这个页面上添加一个描述。

环顾四周,我发现了另一个问题。基本上这正是我想要的,但我真的不明白脚本是如何工作的。

如果我添加CurPageChanged(CurPageID: Integer)程序,我怎么能告诉它改变FileTemplatePage?我必须把它放在哪里?我不应该把类似的东西放在CurPageChanged(FileTemplatePage.ID)里面InitializeWizard吗?

一般来说,我很难理解[Code]零件的工作原理,难道没有主要功能吗?

我可以编译和使用这个脚本,并且可以将文本可视化到安装页面中,因为Parent就是这样,我该如何更改Parent?。

我试图这样做:CustomStatusLabel.Parent := FileTemplatePage,但我得到了错误Type mismatch

你有什么建议吗?谢谢。

标签: inno-setup

解决方案


推荐阅读