Genri
Advanced Member | Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору
Код: [Setup] AppName=My Program AppVerName=My Program version 1.5 Uninstallable=No DisableProgramGroupPage=Yes CreateAppDir=No AlwaysShowDirOnReadyPage=Yes [Files] #define MaxTarget 200 #define i #sub AddFile Source: Files\*; DestDir: {code:CurrentDir|{#i}}; Check: NeedCopy(ExpandConstant('{#i}')) #endsub #for {i = 0; i < MaxTarget; i++} AddFile [Run] #sub RunFile Filename: "{code:RunDir|{#i}}\Archive.exe"; StatusMsg: Распаковка форм {code:RunDir|{#i}}; BeforeInstall: ChangeProgress(ExpandConstant('{#i}')) ; Flags: skipifdoesntexist #endsub #for {i = 0; i < MaxTarget; i++} RunFile [Code] var Names: TArrayOfString; Value: TArrayOfString; Page: TInputOptionWizardPage; ProgressBar: TNewProgressBar; SelectAll: TButton; function NeedCopy(Param: string): Boolean; begin if (StrToInt(Param) < Page.CheckListBox.Items.Count) and Page.CheckListBox.Checked[StrToInt(Param)] then begin Result:= True; end; end; function CurrentDir(Param: string): string; begin if Page.CheckListBox.Checked[StrToInt(Param)] then Result:= Page.CheckListBox.ItemSubItem[StrToInt(Param)] else Result:= ''; end; function RunDir(Param: string): string; begin if (StrToInt(Param) < Page.CheckListBox.Items.Count) and Page.CheckListBox.Checked[StrToInt(Param)] then Result:= Page.CheckListBox.ItemSubItem[StrToInt(Param)] else Result:= ''; end; procedure ChangeProgress(Param: string); begin if (StrToInt(Param) < Page.CheckListBox.Items.Count) and Page.CheckListBox.Checked[StrToInt(Param)] then ProgressBar.Position:= ProgressBar.Position + 1; end; procedure CurPageChanged(CurPageID: Integer); var i: integer; begin if CurPageID = wpReady then begin with WizardForm.ReadyMemo.Lines do begin Clear; Add('Destination location:'); for i:= 0 to Page.CheckListBox.Items.Count - 1 do begin if Page.CheckListBox.Checked[i] then Add(#9 + Page.CheckListBox.ItemSubItem[i] + ' - ' + Page.CheckListBox.ItemCaption[i]); end; end; end; if CurPageID = Page.ID then begin SelectAll.Visible:= True; end else SelectAll.Visible:= False; end; procedure CurStepChanged(CurStep: TSetupStep); var CheckedCount, i: integer; begin if CurStep = ssInstall then begin CheckedCount:= 0; for i:= 0 to Page.CheckListBox.Items.Count - 1 do begin if Page.CheckListBox.Checked[i] then CheckedCount:= CheckedCount + 1; end; with WizardForm.ProgressGauge do begin ProgressBar := TNewProgressBar.Create(WizardForm); ProgressBar.Left := Left; ProgressBar.Top := Top + Height + ScaleY(8); ProgressBar.Width := Width; ProgressBar.Height := Height; ProgressBar.Parent := WizardForm.InstallingPage; ProgressBar.Max := CheckedCount; ProgressBar.Position := 0; end; end; end; function NextButtonClick(CurPageID: Integer): Boolean; var i: integer; begin if CurPageID = Page.ID then begin Result := False; for i:= 0 to Page.CheckListBox.Items.Count - 1 do begin if (Page.CheckListBox.Checked[i]) then begin Result := True; Break; end; end; if Not Result then MsgBox('Выберите хотя бы один путь установки !', mbInformation, MB_OK); end else begin Result := True; end; end; procedure ButtonOnClick(Sender: TObject); var i: integer; begin if (SelectAll.Tag = 0) then begin for i:= 0 to Page.CheckListBox.Items.Count - 1 do begin Page.CheckListBox.Checked[i]:= True; end; SelectAll.Caption := 'Очистить все'; SelectAll.Tag:= 1; end else if (SelectAll.Tag = 1) then begin for i:= 0 to Page.CheckListBox.Items.Count - 1 do begin Page.CheckListBox.Checked[i]:= False; end; SelectAll.Caption := 'Выбрать все'; SelectAll.Tag:= 0; end; end; procedure InitializeWizard(); var I: Integer; S: String; begin Page := CreateInputOptionPage(wpWelcome, 'Выберите компоненты', 'Какие компоненты хотите установить?', 'Выберите необходимые компоненты и нажмите далее.', False, True); SelectAll:= TButton.Create(WizardForm); SelectAll.Width := WizardForm.BackButton.Width + ScaleX(10); SelectAll.Height := WizardForm.BackButton.Height; SelectAll.Top := WizardForm.BackButton.Top; SelectAll.Left := WizardForm.BackButton.Left - WizardForm.BackButton.Width - ScaleX(40); SelectAll.OnClick := @ButtonOnClick; SelectAll.Parent := WizardForm; SelectAll.Visible:= False; SelectAll.Caption := 'Выбрать все'; SelectAll.Tag:= 0; if RegGetValueNames(HKEY_CURRENT_USER, 'Software\My Program\Path', Names) then begin SetArrayLength(Value,GetArrayLength(Names)); for I := 0 to GetArrayLength(Names)-1 do begin RegQueryStringValue(HKEY_CURRENT_USER, 'Software\My Program\Path', Names[I], Value[I]); Page.CheckListBox.AddCheckBox(Value[I], Names[I], 0, False, True, False, False, nil); end; end; end; | Для тестирования данного скрипта, можно использовать следующий *.reg файл: Windows Registry Editor Version 5.00 [HKEY_CURRENT_USER\Software\My Program\Path] "C:\\My Program\\Work"="База рабочая" "C:\\My Program\\Info"="Информационная база" "C:\\My Program\\Test"="База для тестов" "C:\\My Program\\Add"="Дополнения" "C:\\My Program\\Admin"="Для администрации" "C:\\My Program\\Filial A"="Филиал 1" "C:\\My Program\\Filial B"="Филиал 2" "C:\\My Program\\Head"="Головная организация" "C:\\My Program\\Rezerved"="Резервировано" Анализ данного скрипта, не составит проблем для тех, кно внимательно изучил хелп Inno Setup | Всего записей: 872 | Зарегистр. 06-09-2003 | Отправлено: 12:46 29-12-2006 | Исправлено: Genri, 14:17 29-12-2006 |
|