spider91
Advanced Member | Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору [Code] const NeedSize = 3700; var NeedSpaceLabel,FreeSpaceLabel: TLabel; FreeMB, TotalMB: Cardinal; ProgressBar1: TNewProgressBar; Dop: TCheckBox; DesktopIcon: TCheckBox; function MakeDesktopIcon: Boolean; begin Result:=DesktopIcon.Checked; end; function InstallDop: Boolean; begin Result:=Dop.Checked; end; procedure GetFreeSpaceCaption(Sender: TObject); var Path: String; begin Path := ExtractFileDrive(WizardForm.DirEdit.Text); GetSpaceOnDisk(Path, True, FreeMB, TotalMB); if FreeMB > 1024 then FreeSpaceLabel.Caption := 'Свободно на выбранном диске: ' + FloatToStr(round(FreeMB/1024*100)/100) + ' GB' else FreeSpaceLabel.Caption := 'Свободно на выбранном диске: ' + IntToStr(FreeMB)+ ' MB'; begin if FreeMB < NeedSize then begin WizardForm.NextButton.Enabled:=false; end else WizardForm.NextButton.Enabled:=true; end; end; procedure InitializeWizard(); begin WizardForm.DiskSpaceLabel.Hide; NeedSpaceLabel := TLabel.Create(WizardForm); with NeedSpaceLabel do begin Parent := WizardForm.SelectDirPage; Left := ScaleX(0); Top := ScaleY(198); Width := ScaleX(209); Height := ScaleY(13); Caption := 'Требуется для установки: xxx GB'; end; FreeSpaceLabel := TLabel.Create(WizardForm); with FreeSpaceLabel do begin Parent := WizardForm.SelectDirPage; Left := ScaleX(0); Top := ScaleY(216); Width := ScaleX(209); Height := ScaleY(13); end; WizardForm.DirEdit.OnChange := @GetFreeSpaceCaption; WizardForm.DirEdit.Text := WizardForm.DirEdit.Text + #0; dop := TCheckBox.Create(WizardForm); with Dop do begin Parent := WizardForm.SelectDirPage; Caption := 'Установить дополнительные программы (рекомендуется)'; Left := ScaleX(0); Top := WizardForm.DirEdit.Top+35; Width := ScaleX(400); Height := ScaleY(15); TabOrder := 0; Checked := True; end; DesktopIcon := TCheckBox.Create(WizardForm); with DesktopIcon do begin Parent := WizardForm.SelectDirPage; Caption := 'Добавить ярлык на рабочий стол'; Left := ScaleX(0); Top := dop.Top + 35; Width := ScaleX(400); Height := ScaleY(15); TabOrder := 0; Checked := True; end; WizardForm.StatusLabel.Caption:='Распаковка файлов...'; WizardForm.FileNameLabel.Visible:=False; WizardForm.ProgressGauge.Top:=ScaleY(65); WizardForm.ProgressGauge.Width:=280; WizardForm.ProgressGauge.Left:=120; WizardForm.StatusLabel.Top:=ScaleY(28); WizardForm.WelcomeLabel2.Top:=ScaleY(90); ProgressBar1 := TNewProgressBar.Create(wizardform); with ProgressBar1 do begin Parent := wizardform.installingpage; Top := 65; Width := 110; Height := wizardform.progressgauge.height; Max :=9; end; end; procedure CurStepChanged(CurStep: TSetupStep); var res:Integer; s,s1:string; begin If CurStep=ssInstall then begin WizardForm.StatusLabel.Caption:='Распаковка файлов...'; ProgressBar1.Position := ProgressBar1.Position+1 s:=ExpandConstant('{src}')+'\data1.bin'; s1:=ExpandConstant('{app}'); Exec(s, '-x -y -d"'+ s1 + '"', '', SW_HIDE, ewWaitUntilTerminated, res); WizardForm.StatusLabel.Caption:='Распаковка файлов...'; ProgressBar1.Position := ProgressBar1.Position+1 s:=ExpandConstant('{src}')+'\data2.bin'; s1:=ExpandConstant('{app}'); Exec(s, '-x -y -d"'+ s1 + '"', '', SW_HIDE, ewWaitUntilTerminated, res); WizardForm.StatusLabel.Caption:='Распаковка файлов...'; ProgressBar1.Position := ProgressBar1.Position+2 s:=ExpandConstant('{src}')+'\data3.bin'; s1:=ExpandConstant('{app}'); Exec(s, '-x -y -d"'+ s1 + '"', '', SW_HIDE, ewWaitUntilTerminated, res); WizardForm.StatusLabel.Caption:='Распаковка файлов...'; ProgressBar1.Position := ProgressBar1.Position+2 s:=ExpandConstant('{src}')+'\data4.bin'; s1:=ExpandConstant('{app}'); Exec(s, '-x -y -d"'+ s1 + '"', '', SW_HIDE, ewWaitUntilTerminated, res); WizardForm.StatusLabel.Caption:='Распаковка файлов...'; ProgressBar1.Position := ProgressBar1.Position+2 s:=ExpandConstant('{src}')+'\data5.bin'; s1:=ExpandConstant('{app}'); Exec(s, '-x -y -d"'+ s1 + '"', '', SW_HIDE, ewWaitUntilTerminated, res); WizardForm.StatusLabel.Caption:='Распаковка файлов...'; ProgressBar1.Position := ProgressBar1.Position+1 end end; procedure CurPageChanged(CurPageID: Integer); begin if CurPageID = wpSelectDir then if FreeMB < NeedSize then begin WizardForm.NextButton.Enabled:=False end; if CurPageID=wpInstalling then begin WizardForm.CancelButton.Enabled := False; end else WizardForm.BackButton.Enabled := True; end; |