Inno Setup-按组件定义磁盘空间 [英] Inno Setup - Define Disk Space by component

查看:92
本文介绍了Inno Setup-按组件定义磁盘空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

默认情况下,在组件"页面上,Inno Setup将内部所有文件的大小添加到所选组件的大小上(显示在页面底部).

By default, on the components page, Inno Setup adds the size of all the files inside to the size of the selected component (shows on the bottom of the page).

现在,我特别需要Inno Setup来精确地要求与当前组件的大小相同的大小.我该如何实现?

Now, I specifically need Inno Setup to require exactly as much as the current component's size is. How can I achieve that?

新代码:

[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}.我现在必须去上班,所以下半天我将处于离线状态.这段代码似乎显示了正确的文件大小,我打算将其他一些功能附加到组件选择上,因此,如果这行得通,我将不得不提出另一个问题.大约8小时后回来.

Posted the full code, since, as you can see, my code changes {app} and {group} depending on the component. I'm gonna have to go to work now, so I'll be offline next half of the day. This code seems to show the correct filesizes, I was going to some other functions attached to component selection, so, if this works I'm gonna have to post another question. Be back in ~8 hours.

推荐答案

您使用的安装程序组件不正确.您的完整包装" 组件不是组件.它是两个组件(第1部分" + 第2部分" )的组合.结果,内置的Inno Setup逻辑与您的安装程序不匹配,现在您问如何解决该问题.请勿尝试解决此问题,而应正确使用Inno Setup.

You are using setup components incorrectly. Your "Full pack" component is not a component. It is a combination of two components ("Part 1" + "Part 2"). As a consequence, the built-in Inno Setup logic does not match with your installer and now you ask how to workaround that. Do not try to workaround that, use Inno Setup correctly instead.

您想要的是两个组成部分:

What you want is two components:

  • 第1部分
  • 第2部分
  • Part 1
  • Part 2

和三种设置类型:

  • 完整包装(同时安装"Part 1" "Part 2" 组件)
  • 第1部分(仅安装第1部分" 组件)
  • 第2部分(仅安装第2部分" 组件)
  • Full pack (installs both "Part 1" and "Part 2" components)
  • Part 1 (installs "Part 1" component only)
  • Part 2 (installs "Part 2" component only)

如果您使用组件而不是类型,是因为您比组合框(下拉菜单)更喜欢单选按钮"选择,请参阅

If you use components instead of types because you like the "radio-button" selection more than the combo box (drop down menu), see Replace installation types Dropdown list by radio buttons.

通过这种方式,您可以获得与屏幕截图相同的GUI,但是可以正常工作.

This way you get the same GUI as on your screenshot, but working correctly.

在您的情况下,根本不显示组件列表是没有意义的.确保没有类型具有iscustom标志以隐藏组件列表,并确保它选择正确的组件(iscustom类型不选择其组件).

In your case it probably does not make sense to show the component list at all. Make sure no type has iscustom flag to hide the components list and also to make sure it selects correct components (iscustom types do not select their components).

如果仍然要显示尺寸标签,请显式显示:

If you want to show the size label anyway, show it explicitly:

procedure InitializeWizard();
begin
  WizardForm.ComponentsDiskSpaceLabel.Visible := True;
end;

如果要显示甚至没有自定义类型的组件列表,请执行以下操作:

If you want to show even the components list with no custom type:

procedure InitializeWizard();
begin
  WizardForm.ComponentsList.Visible := True;
  WizardForm.ComponentsDiskSpaceLabel.Visible := True;
end;

这篇关于Inno Setup-按组件定义磁盘空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆