jeudi 10 août 2017

Inno Setup: hide checkbox dynamically by condition

sorry for my poor english. I would make an installer with a custom page with checkbox for install many optional progs. The checkboxes must be visible if several conditions is true, hidden if false. (for example windows version and architecture). A checkbox for a program must be always visible and checkable. I try to use a modified code of this page Inno Setup - Dynamic positioning of controls/checkboxes but there is many errors compiling the script. I can make this using Component or Task and check parameter, but i need to have a dedicated page for this operation.

This is the code

[Code]
function IsWindowsVersionOrNewer(Major, Minor: Integer): Boolean;
var
  Version: TWindowsVersion;
begin
  GetWindowsVersionEx(Version);
  Result :=
    (Version.Major > Major) or
    ((Version.Major = Major) and (Version.Minor >= Minor));
end;

function IsWindowsXPOrNewer: Boolean;
begin
  Result := IsWindowsVersionOrNewer(5, 1);
end;

var  
  Page: TInputOptionWizardPage;
  Progs: TStringList;

procedure AddCheckbox(Condition: boolean; Caption: string);
begin
  if Condition = true then
  begin
    Comps.Add(Condition);
    Progs.Add(Caption);
  end;
end;

procedure InitializeWizard;
begin
Page :=
CreateInputOptionPage(
  wpSelectComponents, 'Install additional', '',
  'Install additional programs.', False, False);
  Comps := TStringList.Create();
  AddCheckbox(isWin64, 'prog1');
  AddCheckbox(IsWindowsXPOrNewer, 'prog2');
  AddCheckbox('', 'prog3'); // This must always be visible and checkable
end;




Aucun commentaire:

Enregistrer un commentaire