Inno Setup将描述文本添加到页面

时间:2018-11-01 16:09:54

标签: 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,以便用户可以添加文件模板。 我要在此页面添加说明。

环顾四周,我发现了另外question个。 基本上,这正是我想要的,但是我真的不了解脚本的工作原理。

如果添加了CurPageChanged(CurPageID: Integer)过程,如何告诉它更改FileTemplatePage? 我必须放在哪里? 我不应该在CurPageChanged(FileTemplatePage.ID)内放置类似InitializeWizard的内容吗?

总的来说,我很难理解[Code]部分的工作原理,不是主要功能吗?

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

我尝试执行以下操作:CustomStatusLabel.Parent := FileTemplatePage,但出现错误Type mismatch

您有什么建议吗?谢谢。

0 个答案:

没有答案