Вопрос Как совместить TNewCheckListBox и TNewComboBox?

Ekspoint

Новичок
Покажите на этом скрипте
Код:
[Setup]
AppName=My Application
AppVersion=1.5
DefaultDirName={pf}\My Application
[CustomMessages]
CompDesc1=Описание первого компонента
CompDesc2=Описание второго компонента
CompDesc3=Описание третьего компонента
CompDesc4=Описание четвертого компонента
CompDesc5=Описание пятого компонента
CompDesc6=Описание шестого компонента
[ISFormDesigner]
WizardForm=FF0A005457495A415244464F524D003010CB04000054504630F10B5457697A617264466F726D0A57697A617264466F726D0C436C69656E744865696768740368010B436C69656E74576964746803F1010C4578706C696369744C65667402000B4578706C69636974546F7002000D4578706C6963697457696474680301020E4578706C69636974486569676874038F010D506978656C73506572496E636802600A54657874486569676874020D00F10C544E65774E6F7465626F6F6B0D4F757465724E6F7465626F6F6B00F110544E65774E6F7465626F6F6B506167650B57656C636F6D65506167650D4578706C69636974576964746803F1010E4578706C696369744865696768740339010000F110544E65774E6F7465626F6F6B5061676509496E6E6572506167650D4578706C69636974576964746803F1010E4578706C6963697448656967687403390100F10C544E65774E6F7465626F6F6B0D496E6E65724E6F7465626F6F6B00F110544E65774E6F7465626F6F6B506167650B4C6963656E7365506167650D4578706C69636974576964746803A1010E4578706C6963697448656967687403ED000000F110544E65774E6F7465626F6F6B506167651453656C656374436F6D706F6E656E747350616765084E65787450616765070D4953437573746F6D50616765310D4578706C69636974576964746803A1010E4578706C6963697448656967687403ED0000F10C544E6577436F6D626F426F780A5479706573436F6D626F0A4974656D486569676874020D000000F110544E65774E6F7465626F6F6B506167651653656C65637450726F6772616D47726F7570506167650C50726576696F757350616765070D4953437573746F6D5061676531000010544E65774E6F7465626F6F6B506167650D4953437573746F6D50616765310743617074696F6E1428000000D0BFD0B5D180D0B2D0B0D18F20D181D182D18020D0BAD0BED0BCD0BFD0BED0BDD0B5D182D0BED0B20C50726576696F757350616765071453656C656374436F6D706F6E656E747350616765084E65787450616765071653656C65637450726F6772616D47726F7570506167650D4578706C69636974576964746802000E4578706C6963697448656967687402000010544E6577436865636B4C697374426F78104E6577436865636B4C697374426F7831044C656674020003546F70024205576964746803A10106486569676874039B00064F666673657402021552657175697265526164696F53656C656374696F6E09085461624F72646572020000000C544E6577436F6D626F426F780C4E6577436F6D626F426F7831044C656674020003546F70021A05576964746803A101064865696768740215055374796C65070E637344726F70446F776E4C6973740A4974656D486569676874020D085461624F72646572020104546578741421000000D09DD0B8D187D0B5D0B3D0BE20D0BDD0B520D0B2D18BD0B1D180D0B0D0BDD0BE210D4974656D732E537472696E6773011415000000D092D18BD0B1D180D0B0D182D18C20D0B2D181D0B51418000000D092D18BD0B1D0BED18020D0B0D0B2D182D0BED180D0B020141F000000D0A3D0B1D180D0B0D182D18C20D0B2D181D0B520D0B3D0B0D0BBD0BAD0B8201421000000D09DD0B8D187D0B5D0B3D0BE20D0BDD0B520D0B2D18BD0B1D180D0B0D0BDD0BE2100094974656D496E646578020300000000000000

[ Code]
{ RedesignWizardFormBegin } // Не удалять эту строку!
// Не изменять эту секцию. Она создана автоматически.
var
  ISCustomPage1: TWizardPage;
  NewCheckListBox1: TNewCheckListBox;
  NewComboBox1: TNewComboBox;

procedure RedesignWizardForm;
begin
  { Creates custom wizard page }
  ISCustomPage1 := CreateCustomPage(wpSelectComponents, 'первая стр компонетов', '');

  { ISCustomPage1 }
  with ISCustomPage1.Surface do
  begin
    Name := 'ISCustomPage1';
  end;

  { NewCheckListBox1 }
  NewCheckListBox1 := TNewCheckListBox.Create(WizardForm);
  with NewCheckListBox1 do
  begin
    Name := 'NewCheckListBox1';
    Parent := ISCustomPage1.Surface;
    Left := ScaleX(0);
    Top := ScaleY(66);
    Width := ScaleX(417);
    Height := ScaleY(155);
    Offset := 2;
  end;

  { NewComboBox1 }
  NewComboBox1 := TNewComboBox.Create(WizardForm);
  with NewComboBox1 do
  begin
    Name := 'NewComboBox1';
    Parent := ISCustomPage1.Surface;
    Left := ScaleX(0);
    Top := ScaleY(26);
    Width := ScaleX(417);
    Height := ScaleY(21);
    Style := csDropDownList;
    Text := 'Ничего не выбрано!';
    Items.Text := 'Выбрать все' + #13#10 +
         'Выбор автора ' + #13#10 +
         'Убрать все галки ' + #13#10 +
         'Ничего не выбрано!';
    ItemIndex := 3;
  end;

  NewCheckListBox1.TabOrder := 0;
  NewComboBox1.TabOrder := 1;

{ ReservationBegin }
  // Вы можете добавить ваш код здесь.
  with NewCheckListBox1 do
  begin
  AddCheckBox(CustomMessage('CompDesc1'), '', 0, False, True, True, True, nil);             //0
      AddRadioButton(CustomMessage('CompDesc2'), '', 1, False, True, nil);                  //1
      AddRadioButton(CustomMessage('CompDesc3'), '', 1, False, True, nil);                  //2
  AddCheckBox(CustomMessage('CompDesc4'), '', 0, False, True, True, True, nil);             //3
      AddRadioButton(CustomMessage('CompDesc5'), '', 1, False, True, nil);                  //4
      AddRadioButton(CustomMessage('CompDesc6'), '', 1, False, True, nil);                  //5
  end;
{ ReservationEnd }
end;
// Не изменять эту секцию. Она создана автоматически.
{ RedesignWizardFormEnd } // Не удалять эту строку!

function IsComponent(CompIndex: Integer): Boolean;
var
i: Integer;
begin
Result := False;
for i := 1 to NewCheckListBox1.ItemCount do
begin
if CompIndex <= (NewCheckListBox1.ItemCount) then
Result := NewCheckListBox1.Checked[CompIndex-1];
end;
end;


procedure InitializeWizard();
begin
  RedesignWizardForm;
end;
 

zettend

Старожил
Ekspoint, Живой пример. Но я так и не разобрался как указывать реестр.
Советую посмотреть в файле ISDone.iss в разделе компонентов.
 

Хамик

Старожил
Ekspoint, Возможно так
Код:
[Setup]
appname=app
AppVersion=1.0
DefaultDirName={sd}\app

[Code]
var
  NewCheckListBox1: TNewCheckListBox;
  NewComboBox1: TNewComboBox;

function IsComponentChecked( const nIndex: Integer ): Boolean;
begin
    Result := NewCheckListBox1.Checked[nIndex];
end;

procedure ChooseType(sender: tobject);
begin
   if NewComboBox1.ItemIndex = 0 then
    begin
      NewCheckListBox1.Checked[1] := True;
      NewCheckListBox1.Checked[2] := True;
      NewCheckListBox1.Checked[5] := True;
      NewCheckListBox1.Checked[4] := false;
    end;

   if NewComboBox1.ItemIndex = 1 then
    begin
      NewCheckListBox1.Checked[1] := True;
      NewCheckListBox1.Checked[5] := false;
      NewCheckListBox1.Checked[2] := false;
      NewCheckListBox1.Checked[4] := True;
    end;
end;

function checklistfull:boolean;
begin
  result := IsComponentChecked(1) and IsComponentChecked(2) and IsComponentChecked(5) and not IsComponentChecked(4);
end;

function checkliststandart:boolean;
begin
  result := IsComponentChecked(1) and IsComponentChecked(4) and not IsComponentChecked(5) and not IsComponentChecked(2);
end;

procedure setcombo(sender: tobject);
var
index: integer;
begin
  case index of
    0:
    begin
    if checklistfull then NewComboBox1.ItemIndex := 0;
    if checkliststandart then NewComboBox1.ItemIndex := 1;
    if not checklistfull and not checkliststandart then NewComboBox1.ItemIndex := 2;
    end;
    1:
    begin
    if checklistfull then NewComboBox1.ItemIndex := 0;
    if checkliststandart then NewComboBox1.ItemIndex := 1;
    if not checklistfull and not checkliststandart then NewComboBox1.ItemIndex := 2;
    end;
    2:
    begin
    if checklistfull then NewComboBox1.ItemIndex := 0;
    if checkliststandart then NewComboBox1.ItemIndex := 1;
    if not checklistfull and not checkliststandart then NewComboBox1.ItemIndex := 2;
    end;
    3:
    begin
    if checklistfull then NewComboBox1.ItemIndex := 0;
    if checkliststandart then NewComboBox1.ItemIndex := 1;
    if not checklistfull and not checkliststandart then NewComboBox1.ItemIndex := 2;
    end;
    4:
    begin
    if checklistfull then NewComboBox1.ItemIndex := 0;
    if checkliststandart then NewComboBox1.ItemIndex := 1;
    if not checklistfull and not checkliststandart then NewComboBox1.ItemIndex := 2;
    end;
    5:
    begin
    if checklistfull then NewComboBox1.ItemIndex := 0;
    if checkliststandart then NewComboBox1.ItemIndex := 1;
    if not checklistfull and not checkliststandart then NewComboBox1.ItemIndex := 2;
    end;
  end;
end;

procedure RedesignWizardForm;
begin
  with WizardForm.WelcomeLabel2 do
  begin
    Height := ScaleY(15);
  end;

  { NewCheckListBox1 }
  NewCheckListBox1 := TNewCheckListBox.Create(WizardForm);
  with NewCheckListBox1 do
  begin
    Parent := WizardForm.WelcomePage;
    Left := ScaleX(176);
    Top := ScaleY(112);
    Width := ScaleX(301);
    Height := ScaleY(113);
    AddCheckBox('test', '', 0, false, true, false,true,nil);    //0 ------
     AddCheckBox('easy', '', 1, true, true, false,true, nil);   //1
     AddCheckBox('full', '', 1, false, true,false, true, nil);  //2
    AddCheckBox('most', '', 0, true, true, false,true,nil);     //3 -------
     AddRadioButton('pack', '', 1, true, true, nil);            //4
     AddRadioButton('build', '', 1, false, true, nil);          //5
   OnClickCheck := @setcombo;
end;

  { NewComboBox1 }
  NewComboBox1 := TNewComboBox.Create(WizardForm);
  with NewComboBox1 do
  begin
    Parent := WizardForm.WelcomePage;
    Left := ScaleX(176);
    Top := ScaleY(240);
    Width := ScaleX(249);
    Height := ScaleY(21);
    Items.Add('full');      //0
    Items.Add('standart');  //1
    Items.Add('custom');    //2
    ItemIndex := 1;
    Style := csDropDownList;
    OnChange := @ChooseType;
  end;
end;

procedure InitializeWizard();
begin
  RedesignWizardForm;
end;
 
Последнее редактирование:

Ekspoint

Новичок
Ekspoint, Возможно так
Код:
[Setup]
appname=app
AppVersion=1.0
DefaultDirName={sd}\app

[Code]
var
  NewCheckListBox1: TNewCheckListBox;
  NewComboBox1: TNewComboBox;

function IsComponentChecked( const nIndex: Integer ): Boolean;
begin
    Result := NewCheckListBox1.Checked[nIndex];
end;

procedure ChooseType(sender: tobject);
begin
   if NewComboBox1.ItemIndex = 0 then
    begin
      NewCheckListBox1.Checked[1] := True;
      NewCheckListBox1.Checked[2] := True;
      NewCheckListBox1.Checked[5] := True;
      NewCheckListBox1.Checked[4] := false;
    end;

   if NewComboBox1.ItemIndex = 1 then
    begin
      NewCheckListBox1.Checked[1] := True;
      NewCheckListBox1.Checked[5] := false;
      NewCheckListBox1.Checked[2] := false;
      NewCheckListBox1.Checked[4] := True;
    end;
end;

function checklistfull:boolean;
begin
  result := IsComponentChecked(1) and IsComponentChecked(2) and IsComponentChecked(5) and not IsComponentChecked(4);
end;

function checkliststandart:boolean;
begin
  result := IsComponentChecked(1) and IsComponentChecked(4) and not IsComponentChecked(5) and not IsComponentChecked(2);
end;

procedure setcombo(sender: tobject);
var
index: integer;
begin
  case index of
    0:
    begin
    if checklistfull then NewComboBox1.ItemIndex := 0;
    if checkliststandart then NewComboBox1.ItemIndex := 1;
    if not checklistfull and not checkliststandart then NewComboBox1.ItemIndex := 2;
    end;
    1:
    begin
    if checklistfull then NewComboBox1.ItemIndex := 0;
    if checkliststandart then NewComboBox1.ItemIndex := 1;
    if not checklistfull and not checkliststandart then NewComboBox1.ItemIndex := 2;
    end;
    2:
    begin
    if checklistfull then NewComboBox1.ItemIndex := 0;
    if checkliststandart then NewComboBox1.ItemIndex := 1;
    if not checklistfull and not checkliststandart then NewComboBox1.ItemIndex := 2;
    end;
    3:
    begin
    if checklistfull then NewComboBox1.ItemIndex := 0;
    if checkliststandart then NewComboBox1.ItemIndex := 1;
    if not checklistfull and not checkliststandart then NewComboBox1.ItemIndex := 2;
    end;
    4:
    begin
    if checklistfull then NewComboBox1.ItemIndex := 0;
    if checkliststandart then NewComboBox1.ItemIndex := 1;
    if not checklistfull and not checkliststandart then NewComboBox1.ItemIndex := 2;
    end;
    5:
    begin
    if checklistfull then NewComboBox1.ItemIndex := 0;
    if checkliststandart then NewComboBox1.ItemIndex := 1;
    if not checklistfull and not checkliststandart then NewComboBox1.ItemIndex := 2;
    end;
  end;
end;

procedure RedesignWizardForm;
begin
  with WizardForm.WelcomeLabel2 do
  begin
    Height := ScaleY(15);
  end;

  { NewCheckListBox1 }
  NewCheckListBox1 := TNewCheckListBox.Create(WizardForm);
  with NewCheckListBox1 do
  begin
    Parent := WizardForm.WelcomePage;
    Left := ScaleX(176);
    Top := ScaleY(112);
    Width := ScaleX(301);
    Height := ScaleY(113);
    AddCheckBox('test', '', 0, false, true, false,true,nil);    //0 ------
     AddCheckBox('easy', '', 1, true, true, false,true, nil);   //1
     AddCheckBox('full', '', 1, false, true,false, true, nil);  //2
    AddCheckBox('most', '', 0, true, true, false,true,nil);     //3 -------
     AddRadioButton('pack', '', 1, true, true, nil);            //4
     AddRadioButton('build', '', 1, false, true, nil);          //5
   OnClickCheck := @setcombo;
end;

  { NewComboBox1 }
  NewComboBox1 := TNewComboBox.Create(WizardForm);
  with NewComboBox1 do
  begin
    Parent := WizardForm.WelcomePage;
    Left := ScaleX(176);
    Top := ScaleY(240);
    Width := ScaleX(249);
    Height := ScaleY(21);
    Items.Add('full');      //0
    Items.Add('standart');  //1
    Items.Add('custom');    //2
    ItemIndex := 0;
    Style := csDropDownList;
    OnChange := @ChooseType;
  end;
end;

procedure InitializeWizard();
begin
  RedesignWizardForm;
end;
Спасибо,работает нормально
А по короче не как не сделать? :)
 

Shegorat

Lord of Madness
Администратор
Можно реорганизовать код, чтобы работа происходила с массивами элементов, как это происходит внутри инно, но объем кода вряд ли уменьшится.
В общем как-то так. Возможно где-то что-то не учел, или забыл. Так что о проблемах сообщаем.
 

Вложения

Сверху