Inno Setup - 按组件定义磁盘 Space
Inno Setup - Define Disk Space by component
默认情况下,在组件页面上,Inno Setup 将内部所有文件的大小添加到所选组件的大小(显示在页面底部)。
现在,我特别需要 Inno Setup 来要求与当前组件的大小完全一样。我怎样才能做到这一点?
新代码:
[Setup]
AppName=Dagon Video Tools
AppVersion=1.0
AppVerName=Dagon Video Tools
DefaultDirName={sd}\Tools\Dagon Video Tools
VersionInfoProductName=Dagon Video Tools
WizardImageFile=Include\WizardImage.bmp
WizardSmallImageFile=Include\WizardSmallImage.bmp
SetupIconFile=Include\Icon.ico
[Files]
.....
[ThirdParty]
UseRelativePaths=True
[Components]
Name: "Slasher"; Description: "Dagon Slasher"; Types: Slasher Full
Name: "Frankenstein"; Description: "Dagon Frankenstein"; Types: Frankenstein Full
[Types]
Name: "Full"; Description: "Full"
Name: "Slasher"; Description: "Dagon Slasher"
Name: "Frankenstein"; Description: "Dagon FrankenStein"
[Icons]
Name: "{group}\{cm:UninstallProgram,Dagon Slasher}"; Filename: "{uninstallexe}"; Components: Slasher
Name: "{group}\{cm:UninstallProgram,Dagon Frankenstein}"; Filename: "{uninstallexe}"; Components: Frankenstein
Name: "{group}\{cm:UninstallProgram,Dagon Video Tools}"; Filename: "{uninstallexe}"; Components: Slasher and Frankenstein
[Code]
procedure CurPageChanged(CurPageID: Integer);
Begin
if (CurPageID=wpSelectProgramGroup) then
begin
if IsComponentSelected('Slasher') then
begin
WizardForm.DirEdit.Text := ExpandConstant('{sd}\Tools\Dagon Slasher');
WizardForm.GroupEdit.Text := 'Dagon Slasher';
end;
if IsComponentSelected('Frankenstein') then
begin
WizardForm.DirEdit.Text := ExpandConstant('{sd}\Tools\Dagon FrankenStein');
WizardForm.GroupEdit.Text := 'Dagon FrankenStein';
end;
if IsComponentSelected('Slasher') and IsComponentSelected('Frankenstein') then
begin
WizardForm.GroupEdit.Text := 'Dagon Video Tools';
end
end;
End;
procedure OnTypeChange(Sender: TObject);
begin
// set the item index in hidden TypesCombo
WizardForm.TypesCombo.ItemIndex := TNewCheckListBox(Sender).ItemIndex;
// notify TypesCombo about the selection change
WizardForm.TypesCombo.OnChange(nil);
end;
procedure InitializeWizard;
var
I: Integer;
CheckListBox: TNewCheckListBox;
begin
// create the TNewCheckListBox object and set the basic properties
CheckListBox := TNewCheckListBox.Create(WizardForm);
CheckListBox.Parent := WizardForm.SelectComponentsPage;
CheckListBox.Left := WizardForm.TypesCombo.Left;
CheckListBox.Top := WizardForm.TypesCombo.Top;
CheckListBox.Width := WizardForm.TypesCombo.Width;
CheckListBox.Height := CheckListBox.MinItemHeight *
WizardForm.TypesCombo.Items.Count + 4;
CheckListBox.TabOrder := 0;
// assign the selection change event
CheckListBox.OnClickCheck := @OnTypeChange;
// add radio buttons from all TypesCombo items, select the first item
for I := 0 to WizardForm.TypesCombo.Items.Count - 1 do
CheckListBox.AddRadioButton(WizardForm.TypesCombo.Items[I],
'', 0, I = 0, True, nil);
// hide the TypesCombo combo box
WizardForm.TypesCombo.Visible := False;
WizardForm.ComponentsList.Visible := False;
WizardForm.ComponentsDiskSpaceLabel.Visible := True;
end;
发布了完整代码,因为如您所见,我的代码根据组件更改 {app}
和 {group}
。我现在要去上班,所以接下来半天我会离线。这段代码似乎显示了正确的文件大小,我正打算使用一些附加到组件选择的其他功能,所以,如果这有效,我将不得不 post 另一个问题。大约 8 小时后回来。
您使用的安装组件不正确。您的 "Full pack" 组件不是组件。它是两个组件的组合 ("Part 1" + "Part 2")。因此,内置的 Inno Setup 逻辑与您的安装程序不匹配,现在您询问如何解决这个问题。不要尝试解决这个问题,而是正确使用 Inno Setup。
你想要的是两个组件:
- 第 1 部分
- 第 2 部分
和三种设置类型:
- 完整包(同时安装"Part 1"和"Part 2" 组件)
- 第 1 部分(仅安装 "Part 1" 组件)
- 第 2 部分(仅安装 "Part 2" 组件)
如果您使用组件而不是类型,因为您更喜欢 "radio-button" selection 而不是组合框(下拉菜单),请参阅 Replace installation types Dropdown list by radio buttons。
通过这种方式,您可以获得与屏幕截图相同的 GUI,但工作正常。
在您的情况下,显示组件列表可能根本没有意义。确保没有类型有 iscustom
标志来隐藏组件列表,并确保它 select 是正确的组件(iscustom
类型没有 select 它们的组件)。
如果您仍然要显示尺码标签,请明确显示:
procedure InitializeWizard();
begin
WizardForm.ComponentsDiskSpaceLabel.Visible := True;
end;
如果您甚至想显示没有自定义类型的组件列表:
procedure InitializeWizard();
begin
WizardForm.ComponentsList.Visible := True;
WizardForm.ComponentsDiskSpaceLabel.Visible := True;
end;
默认情况下,在组件页面上,Inno Setup 将内部所有文件的大小添加到所选组件的大小(显示在页面底部)。
现在,我特别需要 Inno Setup 来要求与当前组件的大小完全一样。我怎样才能做到这一点?
新代码:
[Setup]
AppName=Dagon Video Tools
AppVersion=1.0
AppVerName=Dagon Video Tools
DefaultDirName={sd}\Tools\Dagon Video Tools
VersionInfoProductName=Dagon Video Tools
WizardImageFile=Include\WizardImage.bmp
WizardSmallImageFile=Include\WizardSmallImage.bmp
SetupIconFile=Include\Icon.ico
[Files]
.....
[ThirdParty]
UseRelativePaths=True
[Components]
Name: "Slasher"; Description: "Dagon Slasher"; Types: Slasher Full
Name: "Frankenstein"; Description: "Dagon Frankenstein"; Types: Frankenstein Full
[Types]
Name: "Full"; Description: "Full"
Name: "Slasher"; Description: "Dagon Slasher"
Name: "Frankenstein"; Description: "Dagon FrankenStein"
[Icons]
Name: "{group}\{cm:UninstallProgram,Dagon Slasher}"; Filename: "{uninstallexe}"; Components: Slasher
Name: "{group}\{cm:UninstallProgram,Dagon Frankenstein}"; Filename: "{uninstallexe}"; Components: Frankenstein
Name: "{group}\{cm:UninstallProgram,Dagon Video Tools}"; Filename: "{uninstallexe}"; Components: Slasher and Frankenstein
[Code]
procedure CurPageChanged(CurPageID: Integer);
Begin
if (CurPageID=wpSelectProgramGroup) then
begin
if IsComponentSelected('Slasher') then
begin
WizardForm.DirEdit.Text := ExpandConstant('{sd}\Tools\Dagon Slasher');
WizardForm.GroupEdit.Text := 'Dagon Slasher';
end;
if IsComponentSelected('Frankenstein') then
begin
WizardForm.DirEdit.Text := ExpandConstant('{sd}\Tools\Dagon FrankenStein');
WizardForm.GroupEdit.Text := 'Dagon FrankenStein';
end;
if IsComponentSelected('Slasher') and IsComponentSelected('Frankenstein') then
begin
WizardForm.GroupEdit.Text := 'Dagon Video Tools';
end
end;
End;
procedure OnTypeChange(Sender: TObject);
begin
// set the item index in hidden TypesCombo
WizardForm.TypesCombo.ItemIndex := TNewCheckListBox(Sender).ItemIndex;
// notify TypesCombo about the selection change
WizardForm.TypesCombo.OnChange(nil);
end;
procedure InitializeWizard;
var
I: Integer;
CheckListBox: TNewCheckListBox;
begin
// create the TNewCheckListBox object and set the basic properties
CheckListBox := TNewCheckListBox.Create(WizardForm);
CheckListBox.Parent := WizardForm.SelectComponentsPage;
CheckListBox.Left := WizardForm.TypesCombo.Left;
CheckListBox.Top := WizardForm.TypesCombo.Top;
CheckListBox.Width := WizardForm.TypesCombo.Width;
CheckListBox.Height := CheckListBox.MinItemHeight *
WizardForm.TypesCombo.Items.Count + 4;
CheckListBox.TabOrder := 0;
// assign the selection change event
CheckListBox.OnClickCheck := @OnTypeChange;
// add radio buttons from all TypesCombo items, select the first item
for I := 0 to WizardForm.TypesCombo.Items.Count - 1 do
CheckListBox.AddRadioButton(WizardForm.TypesCombo.Items[I],
'', 0, I = 0, True, nil);
// hide the TypesCombo combo box
WizardForm.TypesCombo.Visible := False;
WizardForm.ComponentsList.Visible := False;
WizardForm.ComponentsDiskSpaceLabel.Visible := True;
end;
发布了完整代码,因为如您所见,我的代码根据组件更改 {app}
和 {group}
。我现在要去上班,所以接下来半天我会离线。这段代码似乎显示了正确的文件大小,我正打算使用一些附加到组件选择的其他功能,所以,如果这有效,我将不得不 post 另一个问题。大约 8 小时后回来。
您使用的安装组件不正确。您的 "Full pack" 组件不是组件。它是两个组件的组合 ("Part 1" + "Part 2")。因此,内置的 Inno Setup 逻辑与您的安装程序不匹配,现在您询问如何解决这个问题。不要尝试解决这个问题,而是正确使用 Inno Setup。
你想要的是两个组件:
- 第 1 部分
- 第 2 部分
和三种设置类型:
- 完整包(同时安装"Part 1"和"Part 2" 组件)
- 第 1 部分(仅安装 "Part 1" 组件)
- 第 2 部分(仅安装 "Part 2" 组件)
如果您使用组件而不是类型,因为您更喜欢 "radio-button" selection 而不是组合框(下拉菜单),请参阅 Replace installation types Dropdown list by radio buttons。
通过这种方式,您可以获得与屏幕截图相同的 GUI,但工作正常。
在您的情况下,显示组件列表可能根本没有意义。确保没有类型有 iscustom
标志来隐藏组件列表,并确保它 select 是正确的组件(iscustom
类型没有 select 它们的组件)。
如果您仍然要显示尺码标签,请明确显示:
procedure InitializeWizard();
begin
WizardForm.ComponentsDiskSpaceLabel.Visible := True;
end;
如果您甚至想显示没有自定义类型的组件列表:
procedure InitializeWizard();
begin
WizardForm.ComponentsList.Visible := True;
WizardForm.ComponentsDiskSpaceLabel.Visible := True;
end;