问题
Is it possible to have a custom page with a drop down list, check boxes, and a button possibly changing the check boxes based on what is chosen from the drop down list. The button will just be used to display a readme text file. I am really not familiar with python scripting but have managed to create a drop down list.
回答1:
You might take a script like this as an inspiration:
[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;
来源:https://stackoverflow.com/questions/16431946/inno-setup-custom-page-with-checkbox-and-dropdown-list