2013-05-08 78 views

回答

6

您可能需要這樣的腳本作爲一個靈感:

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

對不起的,我沒有看到如何接受一個答案。再次感謝 – grahamskaraoke 2013-05-09 02:16:53

+0

不客氣! – TLama 2013-05-09 06:24:33

+0

@TLama對不起,這麼晚了。但是有沒有辦法在稍後引用複選框?類似於檢查組件? – WASasquatch 2014-09-08 20:58:17