Вопрос Component of Inno Setup that is an optional part of “full” installation type

nizcoz

Участник
I am using this code to install my program and the possibility of install ¨Extras¨ and install DirectX:

Код:
[types]

Name: "full"; Description: "{cm:FullInstallation}"
Name: "custom"; Description: "{cm:CustomInstallation}"; Flags: iscustom

[Components]

Name: "program"; Description: "{cm:ProgramFilesComponent}"; Types: full custom; \
    Flags: fixed
Name: "Extras"; Description: "{cm:ReadmeFileComponent}"
Name: "DirectX"; Description: "{cm:InstalarDirectX}"
The idea is that when you select to install DirectX, do not change the type of installation. That is, if the installation is full or custom, do not change that classification, if I choose to install DirectX. Is this possible?
 

sergey3695

Ветеран
Модератор
if create TypesComboBox
Код:
[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}\My Program
DefaultGroupName=My Program
OutputDir=.

[Types]
Name: "full"; Description: "FullInstallation"; Flags: iscustom

[Components]
Name: "program"; Description: "ProgramFilesComponent"; Types: full; Flags: fixed
Name: "Extras"; Description: "ReadmeFileComponent"; Types: full;
Name: "DirectX"; Description: "InstalarDirectX"; Types: full;

[Code]
var
    OldCompListOnClickCheckProc: TNotifyEvent;
    ComboBoxC: TNewComboBox;

procedure ComboBoxCOnChange(Sender: TObject);
begin
if ComboBoxC.ItemIndex=0 then
begin
  WizardForm.ComponentsList.Checked[1]:= True;
end;
if ComboBoxC.ItemIndex=1 then
begin
  WizardForm.ComponentsList.Checked[1]:= False;
end;
end;

procedure ComponentsListOnClickCheck(Sender: TObject);
begin
if WizardForm.ComponentsList.Checked[1] then
  ComboBoxC.ItemIndex:= 0
else
  ComboBoxC.ItemIndex:= 1;
//
  OldCompListOnClickCheckProc(nil);
end;

procedure InitializeWizard();
begin
  ComboBoxC := TNewComboBox.Create(WizardForm);
  with ComboBoxC do
  begin
    Parent := WizardForm.SelectComponentsPage;
    Left := WizardForm.ComponentsList.Left;
    Top := WizardForm.ComponentsList.Top;
    Width := WizardForm.ComponentsList.Width;
    Height := ScaleY(21);
    Style := csDropDownList;
    Items.Add(SetupMessage(msgFullInstallation));
    Items.Add(SetupMessage(msgCustomInstallation));
    ItemIndex:= 0;
    OnChange:= @ComboBoxCOnChange;
  end;
  WizardForm.ComponentsList.Top:= WizardForm.ComponentsList.Top + ScaleX(26);
  WizardForm.ComponentsList.Height:= WizardForm.ComponentsList.Height - ScaleY(26);
  OldCompListOnClickCheckProc := WizardForm.ComponentsList.OnClickCheck;
  WizardForm.ComponentsList.OnClickCheck := @ComponentsListOnClickCheck;
end;
 
Последнее редактирование:

Nemko

Дилетант
Модератор
nizcoz, сan be useful as an example (edit, fix bugs):

Код:
[Setup]
AppName=My Application
AppVersion=1.5
DefaultDirName={pf}\My Application

[Types]
Name: "full"; Description: "Full"
Name: "custom"; Description: "Custom"; Flags: iscustom

[Components]
Name: "Cmp_1"; Description: "Component 1"; Types: full custom;
Name: "Cmp_2"; Description: "Component 2";
Name: "Cmp_3"; Description: "Component 3";
Name: "Cmp_4"; Description: "Component 4";
Name: "Cmp_5"; Description: "Install DirectX";

[Code]
var
  IndexOnEnter, FindIndexByName: Integer;
  OldEvent_ComponentsListClickCheck: TNotifyEvent;

function FindCmpByName(Name: String): Integer;
var
  i: integer;
begin
for i:=0 to WizardForm.ComponentsList.ItemCount do begin
  if Pos(Lowercase(Name), Lowercase(WizardForm.ComponentsList.Items[i])) > 0 then begin
  FindIndexByName:=i;
  Exit;
  end else Continue;
 end;
 Result:=FindIndexByName;
end;

procedure ComponentsListClickCheck(Sender: TObject);
var
  oldcheckindex: Integer;
begin
if (FindIndexByName <> 0) and (IndexOnEnter <> -1) and (FindIndexByName = IndexOnEnter) then
begin
  oldcheckindex:=WizardForm.TypesCombo.ItemIndex;
  OldEvent_ComponentsListClickCheck(Sender);
  WizardForm.TypesCombo.ItemIndex:=oldcheckindex;
 end else OldEvent_ComponentsListClickCheck(Sender);
end;

procedure ComponentsListItemMouseMove(Sender: TObject; X: Integer; Y: Integer; Index: Integer; Area: TItemArea);
begin
  IndexOnEnter:=Index;
end;

procedure InitializeWizard;
begin
with WizardForm.ComponentsList do begin
  OldEvent_ComponentsListClickCheck:=OnClickCheck;
  FindIndexByName:=FindCmpByName('DirectX');
  OnItemMouseMove:=@ComponentsListItemMouseMove;
  OnClickCheck:=@ComponentsListClickCheck;
 end;
end;
 
Последнее редактирование:

sergey3695

Ветеран
Модератор
Nemko, заморочено, тоже так подумал, но нет, если отмечен DirectX тип не меняется, что не есть решение. :D
 

Nemko

Дилетант
Модератор
sergey3695, я оказался более упёртым, чем думал (Возможно Автору темы уже и помощь то не нужна моя :) ).

nizcoz, look at this:
Код:
[Setup]
AppName=My Application
AppVersion=1.5
DefaultDirName={pf}\My Application

[Types]
Name: "full"; Description: "Full"
Name: "custom"; Description: "Custom"; Flags: iscustom

[Components]
Name: "Cmp_1"; Description: "Component 1"; Types: full custom; Flags: fixed;
Name: "Cmp_2"; Description: "Component 2";
Name: "Cmp_3"; Description: "Component 3";
Name: "Cmp_4"; Description: "Component 4";
Name: "Cmp_5"; Description: "Install DirectX";

[Code]
var
  IndexOnEnter, FindIndexByName: Integer;
  OldEvent_ComponentsListClickCheck: TNotifyEvent;

function FindCmpByName(Name: String): Integer;
var
  i: integer;
begin
for i:=0 to WizardForm.ComponentsList.ItemCount-1 do begin
  if Pos(Lowercase(Name), Lowercase(WizardForm.ComponentsList.Items[i])) > 0 then begin
  FindIndexByName:=i;
  Exit;
  end else Continue;
 end;
 Result:=FindIndexByName;
end;

procedure ComponentsListClickCheck(Sender: TObject);
var
  oldcheckindex: Integer;
begin
if (FindIndexByName <> 0) and (IndexOnEnter <> -1) then begin
if (FindIndexByName = IndexOnEnter) then begin
  oldcheckindex:=WizardForm.TypesCombo.ItemIndex;
  OldEvent_ComponentsListClickCheck(Sender);
  WizardForm.TypesCombo.ItemIndex:=oldcheckindex;
end else begin
  if TNewCheckListBox(Sender).Checked[FindIndexByName] then begin
  TNewCheckListBox(Sender).Checked[FindIndexByName]:=False;
  oldcheckindex:=WizardForm.TypesCombo.ItemIndex;
  WizardForm.TypesCombo.ItemIndex:=oldcheckindex;
  OldEvent_ComponentsListClickCheck(Sender);
  TNewCheckListBox(Sender).Checked[FindIndexByName]:=True;
 end else OldEvent_ComponentsListClickCheck(Sender);
end;
 end else OldEvent_ComponentsListClickCheck(Sender);
end;

procedure ComponentsListItemMouseMove(Sender: TObject; X: Integer; Y: Integer; Index: Integer; Area: TItemArea);
begin
  IndexOnEnter:=Index;
end;

procedure InitializeWizard;
begin
with WizardForm.ComponentsList do begin
  OldEvent_ComponentsListClickCheck:=OnClickCheck;
  FindIndexByName:=FindCmpByName('DirectX');
  OnItemMouseMove:=@ComponentsListItemMouseMove;
  OnClickCheck:=@ComponentsListClickCheck;
 end;
end;
 
Последнее редактирование:

sergey3695

Ветеран
Модератор
Немного переделал, про ComponentsListItemMouseMove даже не подумал.
Код:
[Setup]
AppName=My Application
AppVersion=1.5
DefaultDirName={pf}\My Application
OutputDir=.

[Types]
Name: "full"; Description: "Full"
Name: "custom"; Description: "Custom"; Flags: iscustom

[Components]
Name: "Cmp_1"; Description: "Component 1"; Types: full custom; Flags: fixed;
Name: "Cmp_2"; Description: "Component 2";
Name: "Cmp_3"; Description: "Component 3";
Name: "Cmp_4"; Description: "Component 4";
Name: "Cmp_5"; Description: "Install DirectX";
Name: "Cmp_5"; Description: "Install Vcredist";

[Code]
var
  IndexOnEnter, FindIndexByName: Integer;
  FindIndexByNameList: TStringList;
  OldEvent_ComponentsListClickCheck: TNotifyEvent;

function FindCmpByName(Name: String): Integer;
var
  i: integer;
begin
  FindIndexByName:= 0;
for i:=0 to WizardForm.ComponentsList.ItemCount-1 do begin
  if Pos(Lowercase(Name), Lowercase(WizardForm.ComponentsList.Items[i])) > 0 then begin
   FindIndexByName:= i;
   Exit;
  end;
end;
  Result:=FindIndexByName;
end;

procedure ComponentsListClickCheck(Sender: TObject);
var
  i: integer;
  n: array [0..100] of integer;
begin
for i := 0 to FindIndexByNameList.Count-1 do
begin
  FindIndexByName:= FindCmpByName(FindIndexByNameList[i]);
if (FindIndexByName = IndexOnEnter) then
  Exit;
end;
for i := 0 to FindIndexByNameList.Count-1 do
begin
  FindIndexByName:= FindCmpByName(FindIndexByNameList[i]);
if (FindIndexByName<>0) and TNewCheckListBox(Sender).Checked[FindIndexByName] then
begin
  n[i]:= FindIndexByName;
  TNewCheckListBox(Sender).Checked[n[i]]:= False;
end;
end;
  OldEvent_ComponentsListClickCheck(Sender);
for i := 0 to FindIndexByNameList.Count-1 do
  TNewCheckListBox(Sender).Checked[n[i]]:= True;
end;

procedure ComponentsListItemMouseMove(Sender: TObject; X: Integer; Y: Integer; Index: Integer; Area: TItemArea);
begin
  IndexOnEnter:=Index;
end;

procedure InitializeWizard;
begin
  FindIndexByNameList := TStringList.Create;
  FindIndexByNameList.Add('DirectX');
  FindIndexByNameList.Add('Vcredist');
with WizardForm.ComponentsList do begin
  OldEvent_ComponentsListClickCheck:=OnClickCheck;
  OnItemMouseMove:=@ComponentsListItemMouseMove;
  OnClickCheck:=@ComponentsListClickCheck;
end;
end;
 
Последнее редактирование:
Сверху