Search code examples
installationinno-setuppascalscript

Inno Setup Disable checkbox if another checkbox is selected


I need to disable some checkbox if another one as been selected yet.
How can I do this?

This is my code:

procedure InitializeWizard();
begin
  AddonPage:= CreateCustomPage(wpSelectTasks,'','Please choose BlueDose preference:');

  CheckListBox := TNewCheckListBox.Create(AddonPage);
  CheckListBox.BorderStyle := bsNone;
  CheckListBox.ParentColor := True;
  CheckListBox.MinItemHeight := WizardForm.TasksList.MinItemHeight;
  CheckListBox.ShowLines := False;
  CheckListBox.WantTabs := True;
  CheckListBox.Parent := AddonPage.Surface;
  CheckListBox.AddGroup('Select Language:', '', 0, nil);
  CheckListBox.AddCheckBox('Italian', '', 0, False, True, False, true, nil);
  CheckListBox.AddCheckBox('English', '', 0, False, True, False, true, nil);
end;

Solution

  • It looks like you do not want checkboxes at all, you want radio buttons:

    CheckListBox.AddRadioButton('Italian', '', 0, False, True, nil);
    CheckListBox.AddRadioButton('English', '', 0, False, True, nil);
    

    enter image description here


    You can also consider using CreateInputOptionPage instead of generic CreateCustomPage. Your code will be much simpler:

    var
      AddonPage: TInputOptionWizardPage;
    
    procedure InitializeWizard();
    begin
      AddonPage :=
        CreateInputOptionPage(
          wpSelectTasks, '', 'Please choose BlueDose preference:', 'Select language',
          True, False);
    
      AddonPage.Add('Italian');
      AddonPage.Add('English');
    end;
    

    enter image description here