inno设置自定义页面,带有复选框和下拉列表

时间:2013-05-08 02:56:58

标签: custom-controls inno-setup

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

1 个答案:

答案 0 :(得分:8)

你可以把这样的剧本作为灵感:

[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;