3

是否可以有一个带有下拉列表、复选框和按钮的自定义页面,可能会根据从下拉列表中选择的内容更改复选框。该按钮将仅用于显示自述文本文件。我真的不熟悉 python 脚本,但设法创建了一个下拉列表。

4

1 回答 1

10

您可能会以这样的脚本为灵感:

[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}\My Program
OutputDir=userdocs:Inno Setup Examples Output

[Files]
Source: "Readme.txt"; Flags: dontcopy

[Code]
var
  Button: TNewButton;
  ComboBox: TNewComboBox;
  CheckBox1: TNewCheckBox;
  CheckBox2: TNewCheckBox;
  CustomPage: TWizardPage;  

procedure ComboBoxChange(Sender: TObject);
begin
  case ComboBox.ItemIndex of
    0:
    begin
      CheckBox1.Checked := True;
      CheckBox2.Checked := False;
    end;
    1:
    begin
      CheckBox1.Checked := False;
      CheckBox2.Checked := True;
    end;
    2:
    begin
      CheckBox1.Checked := True;
      CheckBox2.Checked := True;
    end;
    3:
    begin
      CheckBox1.Checked := False;
      CheckBox2.Checked := False;
    end;
  end;
end;

procedure ButtonClick(Sender: TObject);
var
  ErrorCode: Integer;
begin
  ExtractTemporaryFile('Readme.txt');
  if not ShellExec('', ExpandConstant('{tmp}\Readme.txt'), '', '', 
    SW_SHOW, ewNoWait, ErrorCode)
  then
    MsgBox(SysErrorMessage(ErrorCode), mbError, MB_OK);
end;

procedure InitializeWizard;
var
  DescLabel: TLabel;
begin
  CustomPage := CreateCustomPage(wpSelectDir, 'Caption', 'Description');

  DescLabel := TLabel.Create(WizardForm);
  DescLabel.Parent := CustomPage.Surface;
  DescLabel.Left := 0;
  DescLabel.Top := 0;
  DescLabel.Caption := 'Select an item...';

  ComboBox := TNewComboBox.Create(WizardForm);
  ComboBox.Parent := CustomPage.Surface;
  ComboBox.Left := 0;
  ComboBox.Top := DescLabel.Top + DescLabel.Height + 6;  
  ComboBox.Width := 220;
  ComboBox.Style := csDropDownList;
  ComboBox.Items.Add('Check CheckBox1');
  ComboBox.Items.Add('Check CheckBox2');
  ComboBox.Items.Add('Check CheckBox1 and CheckBox2');
  ComboBox.Items.Add('Uncheck CheckBox1 and CheckBox2');
  ComboBox.OnChange := @ComboBoxChange;

  CheckBox1 := TNewCheckBox.Create(WizardForm);
  CheckBox1.Parent := CustomPage.Surface;
  CheckBox1.Left := 0;
  CheckBox1.Top := ComboBox.Top + ComboBox.Height + 6;
  CheckBox1.Caption := 'CheckBox1';

  CheckBox2 := TNewCheckBox.Create(WizardForm);
  CheckBox2.Parent := CustomPage.Surface;
  CheckBox2.Left := 0;
  CheckBox2.Top := CheckBox1.Top + CheckBox1.Height + 6;
  CheckBox2.Caption := 'CheckBox2';

  Button := TNewButton.Create(WizardForm);
  Button.Parent := CustomPage.Surface;
  Button.Left := 0;
  Button.Top := CheckBox2.Top + CheckBox2.Height + 6;
  Button.Caption := 'Readme';
  Button.OnClick := @ButtonClick;
end;
于 2013-05-08T13:17:21.197 回答