doombuster Цитата: как к этим 4 файлам собственный ProgressBar прикрутить?
[more=попробуйте]
Код: [Setup]
AppName=Lost Planet Colonies
AppVerName=Lost Planet Colonies
DefaultDirName=D:\Games\Lost Planet Colonies
OutputBaseFilename=Setup
Compression=lzma/ultra64
SolidCompression=yes
DiskSpanning=true
SlicesPerDisk=3
DiskSliceSize=1100000000
InternalCompressLevel=ultra64
OutputDir=D:\test\lp_ce
WizardImageFile=D:\test\lp.bmp
WizardSmallImageFile=D:\test\lp_small.bmp
DisableProgramGroupPage=true
DefaultGroupName=Lost Planet Colonies
VersionInfoVersion=1.0.0.0
DirExistsWarning=no
DisableReadyPage=true
AppVersion=1.0.0.0
UninstallDisplayName=Lost Planet Colonies
[Languages]
Name: rus; MessagesFile: compiler:\Languages\Russian.isl
[LangOptions]
WelcomeFontSize=10
[Icons]
Name: {group}\Lost Planet Colonies; Filename: {app}\LPCLauncher.exe; WorkingDir: {app}
Name: {group}\Удалить игру; Filename: {uninstallexe}
Name: {userdesktop}\Lost Planet Colonies; Filename: {app}\LPCLauncher.exe; WorkingDir: {app}
[Files]
Source: D:\test\logo.bmp;DestDir:{tmp};Flags: dontcopy nocompression solidbreak
Source: D:\Games\Lost Planet Colonies\*; DestDir: {app}; Flags: ignoreversion createallsubdirs recursesubdirs sortfilesbyextension
Source: D:\test\NOCOMP\ZZPack1.exe; DestDir: {app}; AfterInstall: Arc(ExpandConstant('{app}\ZZPack1.exe'), ExpandConstant('{app}\Papka\')); Flags: ignoreversion
Source: D:\test\NOCOMP\ZZPack1_2.exe; DestDir: {app}; AfterInstall: Arc(ExpandConstant('{app}\ZZPack1_2.exe'), ExpandConstant('{app}\Papka\')); Flags: ignoreversion
Source: D:\test\NOCOMP\ZZPack2.exe; DestDir: {app}; AfterInstall: Arc(ExpandConstant('{app}\ZZPack2.exe'), ExpandConstant('{app}\Papka\')); Flags: ignoreversion
Source: D:\test\NOCOMP\ZZPack2_2.exe; DestDir: {app}; AfterInstall: Arc(ExpandConstant('{app}\ZZPack2_2.exe'), ExpandConstant('{app}\Papka\')); Flags: ignoreversion
Код: //////////////
type
TProc = procedure(HandleW, msg, idEvent, TimeSys: LongWord);
const
NeedSize = 7760;
var
PageNameLabel, PageDescriptionLabel: TLabel;
DesktopIcon: TCheckBox;
LogoImage:TBitmapImage;
LogoPanel: TPanel;
LogoLabel: TLabel;
FreeMB, TotalMB: Cardinal;
NeedSpaceLabel, FreeSpaceLabel: TLabel;
ExtractFile: TNewStaticText;
TimerID: LongWord;
pfunc: LongWord;
Label1: Tlabel;
WLabel1, WLabel2: TLabel;
FLabel1, FLabel2: TLabel;
ProgressBar1: TNewProgressBar;
/////////
function MakeDesktopIcon: Boolean;
begin
Result:= DesktopIcon.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';
if FreeMB < NeedSize then
WizardForm.NextButton.Enabled := false
else
WizardForm.NextButton.Enabled := true;
end;
//////////
procedure LogoLabelOnClick(Sender: TObject);
var
ErrorCode: Integer;
begin
ShellExec('open', 'http://kirovmedia.ru/forum', '', '', SW_SHOWNORMAL, ewNoWait, ErrorCode)
end;
procedure InitializeWizard();
begin
with WizardForm do
begin
WelcomeLabel1.Hide;
WelcomeLabel2.Hide;
PageNameLabel.Hide;
PageDescriptionLabel.Hide;
DiskSpaceLabel.Hide;
FinishedHeadingLabel.Hide;
FinishedLabel.Hide;
WizardSmallBitmapImage.Left := ScaleX(0);
WizardSmallBitmapImage.Top := ScaleY(0);
WizardSmallBitmapImage.Width := WizardForm.MainPanel.Width;
WizardSmallBitmapImage.Height := WizardForm.MainPanel.Height;
PageDescriptionLabel.Width:=300;
PageNameLabel.Width:=300;
WizardBitmapImage.Width := WizardForm.Width;
WizardBitmapImage.Height := WizardForm.Height;
WizardBitmapImage2.Width := WizardForm.Width;
WizardBitmapImage2.Height := WizardForm.Height;
end;
DesktopIcon := TCheckBox.Create(WizardForm);
with DesktopIcon do
begin
Parent := WizardForm.SelectDirPage;
Caption := 'Добавить ярлык на рабочий стол';
Left := ScaleX(0);
Top := ScaleY(WizardForm.DirEdit.Top + 35);
Width := ScaleX(400);
Height := ScaleY(15);
TabOrder := 0;
Checked := True;
end;
////////////
FLabel1 := TLabel.Create(WizardForm);
with FLabel1 do
begin
Left := ScaleX(176);
Top := ScaleY(16);
Width := ScaleX(301);
Height := ScaleY(54);
AutoSize := False;
WordWrap := True;
Font.Size := 12;
Font.Style := [fsBold];
Font.Color:= clblack;
ShowAccelChar := False;
Caption := WizardForm.FinishedHeadingLabel.Caption;
Transparent := True;
Parent := WizardForm.FinishedPage;
end;
FLabel2 :=TLabel.Create(WizardForm);
with FLabel2 do
begin
Top := ScaleY(76);
Left := ScaleX(176);
Width := ScaleX(301);
Height := ScaleY(53); // во втором варианте ScaleY(77);
AutoSize := False;
WordWrap := True;
Font.Color:= clblack;
ShowAccelChar := False;
Caption := 'Программа установлена на Ваш компьютер.' #13#13
'Нажмите «Завершить», чтобы выйти из программы установки.';
Transparent := True;
Parent := WizardForm.FinishedPage
end;
WLabel1 := TLabel.Create(WizardForm);
with WLabel1 do
begin
Left := ScaleX(176);
Top := ScaleY(16);
Width := ScaleX(301);
Height := ScaleY(54); // во втором варианте ScaleY(100);
AutoSize := False;
WordWrap := True;
Font.Size := 12;
Font.Style := [fsBold];
Font.Color:= clblack;
ShowAccelChar := False;
Caption := WizardForm.WelcomeLabel1.Caption;
Transparent := True;
Parent := WizardForm.WelcomePage;
end;
WLabel2:=TLabel.Create(WizardForm);
with WLabel2 do
begin
Top := ScaleY(76);
Left := ScaleX(176);
Width := ScaleX(301);
Height := ScaleY(234);
AutoSize := False;
WordWrap := True;
Font.Color:= clblack;
ShowAccelChar := False;
Caption := WizardForm.WelcomeLabel2.Caption;
Transparent := True;
Parent := WizardForm.WelcomePage;
end;
//////////
NeedSpaceLabel := TLabel.Create(WizardForm);
with NeedSpaceLabel do
begin
Parent := WizardForm.SelectDirPage;
Left := ScaleX(0);
Top := ScaleY(198);
Width := ScaleX(209);
Height := ScaleY(13);
Caption := 'Требуется место на диске: 7,57 GB' ;
end;
////////////
PageNameLabel := TLabel.Create(WizardForm);
with PageNameLabel do
begin
Left := ScaleX(45);
Top := ScaleY(10);
Width := ScaleX(300);
Height := ScaleY(14);
AutoSize := False;
WordWrap := True;
Font.Color := clwhite;
Font.Style := [fsBold];
Transparent := True;
Parent := WizardForm.MainPanel;
end;
PageDescriptionLabel := TLabel.Create(WizardForm);
with PageDescriptionLabel do
begin
Left := ScaleX(45);
Top := ScaleY(25);
Width := ScaleX(475);
Height := ScaleY(30);
AutoSize := False;
WordWrap := True;
Font.Color := clwhite;
Transparent := True;
Parent := WizardForm.MainPanel;
end;
////////////IntToStr(NeedSize) + ' GB'
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;
/////////////////
LogoPanel := TPanel.Create(WizardForm);
with LogoPanel do
begin
Parent := WizardForm;
Left := ScaleX(8);
Top := ScaleY(327);
Width := ScaleX(120);
Height := ScaleY(28);
BevelOuter := bvNone;
end;
LogoImage := TBitmapImage.Create(WizardForm);
with LogoImage do
begin
Parent := LogoPanel;
Left := ScaleX(0);
Top := ScaleY(0);
AutoSize:=true;
ReplaceColor:=clFuchsia;
ReplaceWithColor:=clBtnFace;
ExtractTemporaryFile('logo.bmp');
Bitmap.LoadFromFile(ExpandConstant('{tmp}\logo.bmp'));
end;
LogoLabel := TLabel.Create(WizardForm);
with LogoLabel do
begin
Parent := LogoPanel;
Width := LogoPanel.Width;
Height := LogoPanel.Height;
Transparent:=True;
Cursor := crHand;
OnClick:=@LogoLabelOnClick;
end;
ProgressBar1 := TNewProgressBar.Create(WizardForm);
with ProgressBar1 do
begin
Parent := WizardForm.InstallingPage;
Left := WizardForm.ProgressGauge.Left;
Top := WizardForm.ProgressGauge.Top + WizardForm.ProgressGauge.Height + 15;
Width := WizardForm.ProgressGauge.Width;
Height := WizardForm.ProgressGauge.Height;
{ указываем на сколько секций разбить прогрессбар, в данном случае у нас 4 архива, вот и делим его на 4 части }
Max := 4; //задается по количеству файлов имеющих AfterInstall: Arc(...
)
end;
end;
procedure Arc(s, s1: string);
var
res: Integer;
begin
Exec(s, '-x -y -dp"'+ s1 + '"', '', SW_SHOWNORMAL, ewWaitUntilTerminated, res);
DeleteFile(s);
ExtractFile.Caption := 'Идёт распаковка данных, пожалуйста подождите...'; // этот текст не будет отбражаться, т.к. не создан - ExtractFile: TNewStaticText.Create(WizardForm);
WizardForm.ProgressGauge.Position:= WizardForm.ProgressGauge.Position + 1;
ProgressBar1.Position := ProgressBar1.Position + 1;
{ чтоб компилятор не ругался на Application, необходима расширенная версия от Restools
,
но должен работать и без Application.ProcessMessages }
// Application.ProcessMessages;
end;
procedure CurPageChanged(CurPageID: Integer);
begin
PageNameLabel.Caption := WizardForm.PageNameLabel.Caption;
PageDescriptionLabel.Caption := WizardForm.PageDescriptionLabel.Caption;
if CurPageID = wpSelectDir then
begin
WizardForm.NextButton.Caption:='Установить';
if FreeMB < NeedSize then
WizardForm.NextButton.Enabled:=False;
end;
end;