PDA

Показать полную графическую версию : Скрипты Inno Setup. Помощь и советы [часть 3]


Страниц : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 [146] 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188

R.i.m.s.k.y.
30-08-2011, 17:04
программирование надо чуток знать, оно упорядочивает мышление

вот ты чего хочешь? чтобы при выбранных компонентах запустилось перекодирование, значит пиши
if (IsComponentSelected('VoiceD2') and IsComponentSelected('VoiceLoD') ) then RecodeOgg;

а когда? когда CurStep = ssPostInstall

но хорошо бы написать что нужно подождать, значит добавляем
ChangeCaption('Конвертация ogg, иди покури');
но добавить надо перед перекодированием, а то перекодируем, потом напишем и никто не заметит, ведь все выполняется последовательно

значит все вместе будет
procedure CurStepChanged(CurStep: TSetupStep);
begin
if CurStep = ssPostInstall then begin
if (IsComponentSelected('VoiceD2') and IsComponentSelected('VoiceLoD') ) then begin
ChangeCaption('Конвертация ogg, иди покури');
RecodeOgg;
end; //if IsComponentSelected
end; //CurStep = ssPostInstall
end;//CurStepChanged

Raf-9600
30-08-2011, 17:37
программирование надо чуток знать, оно упорядочивает мышление »
Да тут кроме упорядоченного мышления, нужно знать некоторые правила "правописания". К примеру для меня не очевидно было, что вся соль в CurStepChanged.

Теперь осталось только сообразить как запустить конвертацию до начала выполнения [Run], и самое главное, объединить код конвертации ogg с кодом выше.

Касательно того что вы написали о CurStepChanged, я не догнал. Там вроде нет параметра указывающего на срабатывания после распаковки всех файлов, но до выполнения [Run].

Нашел в гугле такую реализацию:

[Run]
Filename: "{app}\MyProgram.exe"; AfterInstall: SomeProc

Но тогда выполняется только одна функция =\

El Sanchez
30-08-2011, 17:58
я бы добавил на конце waituntilterminated и WorkingDir »
R.i.m.s.k.y., в данном случае ни то, ни другое не нужно. WorkingDir не нужен, т.к . путь уже передан в for. waituntilterminated используется совместно с флагом shellexec, без shellexec же waituntilterminated - это дефолт.

как сделать чтобы событие наступало сразу после первого клика?
если так, то только после второго »
Sollar, приведенные коды корректно работать не будут. Сдается мне, что вы хотите какие-то ненужные действия с задачами изобрести. Нужно нормально поставленное задание. Хочу деталей! © "А.Е. Быков, Интерны"

El Sanchez
30-08-2011, 18:16
Теперь осталось только сообразить как запустить конвертацию до начала выполнения [Run] »
Raf-9600, ну так и пишите первой срокой в [Run] конвертацию кодом, который я давал раньше. [Run] выполняется как раз после установки файлов и до ssPostInstall (у вас в коде выше конвертация производится над уже установленными/распакованными файлами).

Raf-9600
30-08-2011, 18:23
El Sanchez, Вы то дали, и я Вам благодарен. Но кто ж знал, что процесс конвертирования можно отображать в виде прогресс-бара? :)

P.S.
Просто у меня ogg конвертируются весьма долго (очень много файлов), посему я и вцепился за идею прогресс-бара..

R.i.m.s.k.y.
30-08-2011, 19:32
C прогрессбаром не подскажу - не знаю

Raf-9600
30-08-2011, 20:01
А касательно объединения кодов, ктонить помочь может? http://i25.fastpic.ru/big/2011/0719/02/b3f16ceb30c04448d52500e216009302.gif

[C0de]
var
Files: Array of String;
S: String;
n: Integer;

Function StringToArray(Text, Cut: String): array of String; var i, k: Integer;
Begin
SetArrayLength(Result, 0); if Cut = '' then Cut:= #1310; //если шаблон пуст, считаем переводы строк
Repeat k:= Pos(Cut,Text);
if k = 1 then begin Delete(Text, 1, Length(Cut)); CONTINUE
end;
SetArrayLength(Result, GetArrayLength(Result) +1); i:= GetArrayLength(Result) -1;
if k = 0 then
Result[i]:=Text
else begin
Result[i]:= Copy(Text, 1, k -1); Delete(Text, 1, Length(Result[i]) + Length(Cut));
end;
Until Length(Text) * k = 0;
End;

procedure FindFiles(FromDir: String; Mask: String);
var FSR, DSR: TFindRec; FindResult: Boolean;
begin
FindResult:= FindFirst(AddBackslash(FromDir)+Mask, FSR)
while FindResult do begin
if FSR.Attributes and FILE_ATTRIBUTE_DIRECTORY = 0 then begin
S:= S + AddBackslash(fromDir) + FSR.Name +'|';
end;
FindResult:= FindNext(FSR);
end;
FindResult:= FindFirst(AddBackslash(FromDir)+ '*.*', DSR)
while FindResult do begin
if ((DSR.Attributes and FILE_ATTRIBUTE_DIRECTORY) = FILE_ATTRIBUTE_DIRECTORY) and not ((DSR.Name = '.') or (DSR.Name = '..')) then begin
FindFiles(AddBackSlash(FromDir)+DSR.Name, Mask)
end;
FindResult:= FindNext(DSR);
end;
FindClose(FSR); FindClose(DSR)
end;

procedure RecodeOgg;
var ResultCode: integer; CurFile: String;
begin
FindFiles(ExpandConstant('{app}'), '*.ogg') //Находим все файлы по маске, в выбранной папке
Files:= StringToArray(S, '|') //Переводим в массив
WizardForm.ProgressGauge.Max:= GetArrayLength(Files)-1; //Получаем кол-во файлов
WizardForm.ProgressGauge.Position:=0
for n:=(GetArrayLength(Files)-1) downto 0 do begin
CurFile:= Files[n]
StringChange(CurFile, AddBackslash(ExpandConstant('{app}')), '')
Exec(ExpandConstant('{app}\oggdec.exe'), '-Q '+AddQuotes(CurFile), '', SW_Hide, EwWaitUntilTerminated, ResultCode) //Для каждого файла запускаем декодер
DeleteFile(Files[n]) //Удаляем ненужный файл
WizardForm.FilenameLabel.Caption:= Files[n]; //Двигаем прогрессбар
WizardForm.ProgressGauge.Position:= WizardForm.ProgressGauge.Position +1;
end;
DeleteFile(ExpandConstant('{app}\oggdec.exe'))
end;

procedure CurStepChanged(CurStep: TSetupStep);
begin
if CurStep = ssPostInstall then begin
if (IsComponentSelected('VoiceD2') and IsComponentSelected('VoiceLoD') ) then begin
ChangeCaption('Конвертация ogg, иди покури');
RecodeOgg;
end; //if IsComponentSelected
end; //CurStep = ssPostInstall
end;//CurStepChanged


#define TIME_FOR_VIEW 10

[C0de]
procedure ChangeCaption(str: string);
begin
WizardForm.StatusLabel.Caption:= str;
end;

function enabledesc(ComponentsListHandle: HWND; DescLabelHandle: HWND; DescStrings: PChar): BOOL; external 'enabledesc@files:descctrl.dll stdcall';

function disabledesc(): BOOL; external 'disabledesc@files:descctrl.dll stdcall';

var
Info: TNewStaticText;
InfoCaption: TNewStaticText;
InfoPanel: TPanel;

NeedSize:Integer;
FreeMB, TotalMB: Cardinal;
NeedSpaceLabel: TLabel;
n: Integer;
VolumeName, FileSystemName: String;
VolumeSerialNo, MaxComponentLength, FileSystemFlags: Longint;
ListBox: TListBox;
StartMenuTreeView: TStartMenuFolderTreeView;

procedure GetFreeSpaceCaption(Sender: TObject);
var
Path: String;
begin
Path := ExtractFileDrive(WizardForm.DirEdit.Text);
GetSpaceOnDisk(Path, True, FreeMB, TotalMB);
if FreeMB < NeedSize then
WizardForm.NextButton.Enabled := False else
WizardForm.NextButton.Enabled := True; end;

procedure GetNeedSpaceCaption;
begin
if NeedSize > 1024 then
NeedSpaceLabel.Caption := 'Требуется как минимум '+ FloatToStr(round(NeedSize/1024*100)/100) + ' Гб свободного дискового пространства.' else
NeedSpaceLabel.Caption := 'Требуется как минимум '+ IntToStr(NeedSize)+ ' Мб свободного дискового пространства.';end;

const oneMB= 1024*1024;
function GetLogicalDrives: DWord; external 'GetLogicalDrives@kernel32.dll stdcall';
function GetDriveType(nDrive: String): Longint; external 'GetDriveTypeA@kernel32.dll stdcall';
function GetVolumeInformation(PathName,VolumeName: PChar; VolumeNameSize,VolumeSerialNumber,MaxComponentLength,FileSystemFlags: Longint; FileSystemName: PChar; FileSystemNameSize: Longint): Longint; external 'GetVolumeInformationA@kernel32.dll stdcall';
function MessageBox(hWnd: Integer; lpText, lpCaption: String; uType: Cardinal): Integer; external 'MessageBoxA@user32.dll stdcall';

Function ByteOrTB(Bytes: Extended; noMB: Boolean): String; { Перевод числа в значение бт/Кб/Мб/Гб/Тб (до 3х знаков после запятой)}
Begin
if not noMB then Result:= FloatToStr(Int(Bytes)) +' Мб' else
if Bytes < 1024 then Result:= FloatToStr(Int(Bytes)) +' Бт' else
if Bytes/1024 < 1024 then Result:= FloatToStr(round((Bytes/1024)*10)/10) +' Кб' else
If Bytes/oneMB < 1024 then Result:= FloatToStr(round(Bytes/oneMB*100)/100) +' Мб' else
If Bytes/oneMB/1000 < 1024 then Result:= FloatToStr(round(Bytes/oneMB/1024*1000)/1000) +' Гб' else
Result:= FloatToStr(round(Bytes/oneMB/oneMB*1000)/1000) +' Тб'
StringChange(Result, ',', '.')
End;

Function DelSP(String: String): String; { Удаление начальных, конечных и повторных пробелов }
Begin while (Pos(' ', String) > 0) do Delete(String, Pos(' ', String), 1); Result:= Trim(String); End;

Function CutString(String: String; MaxLength: Longint): String; { Обрезать строку до заданного кол-ва символов}
Begin
if Length(String) > MaxLength then Result:= Copy(String, 1, 6) +'...'+ Copy(String, Length(String) - MaxLength +9, MaxLength)
else Result:= String;
End;

Procedure GetDiskInfo(Disk: String);
Begin
FileSystemName:= StringOfChar(' ', 32); VolumeName:= StringOfChar(' ', 256);
GetVolumeInformation(Disk, VolumeName, 255, VolumeSerialNo, MaxComponentLength, FileSystemFlags, FileSystemName, 31);
FileSystemName:= DelSp(FileSystemName); VolumeName:= DelSp(VolumeName); if VolumeName='' then VolumeName:='без метки';
End;

Procedure ListBoxRefresh; var FreeB, TotalB: Cardinal; Path, String: string; Begin
ListBox.Items.Clear
for n:= 1 to 31 do // диск 'А' пропустить
if (GetLogicalDrives and (1 shl n)) > 0 then
if (GetDriveType(Chr(ord('A') + n) +':\') = 2) or (GetDriveType(Chr(ord('A') + n) +':\') = 3) then
if GetSpaceOnDisk(Chr(ord('A') + n) +':\', True, FreeMB, TotalMB) then ListBox.Items.Add(Chr(ord('A') + n) +':');
for n:= 0 to ListBox.Items.Count -1 do begin
Path:= Copy(ListBox.Items[n],1,2) +'\' { если в накопителе нет диска, пропустить обновление }
if GetSpaceOnDisk(Path, False, FreeB, TotalB) and GetSpaceOnDisk(Path, True, FreeMB, TotalMB) then begin GetDiskInfo(Path);
if FreeB >= $7FFFFFFF then String:= PadL(ByteOrTB(FreeMB*oneMB, true),10) else String:= PadL(ByteOrTB(FreeB, true),10);
if TotalB >= $7FFFFFFF then begin TotalB:= TotalMB; FreeB:= FreeMB; String:= PadL(ByteOrTB(TotalMB*oneMB, true),11) +' всего -'+ String end else String:= PadL(ByteOrTB(TotalB, true),11) +' всего| '+ String;
ListBox.Items[n]:= Copy(Path,1,2) + String + PadL(FloatToStr(round(FreeB/TotalB*100)),3)+ '% своб|'+ PadL(FileSystemName,5)+ '| '+ CutString(VolumeName,9); end; end;
End;

Procedure ObjectOnClick(Sender: TObject); Begin
Case TObject(Sender) of
ListBox: for n:= 0 to ListBox.Items.Count-1 do if ListBox.Selected[n] then WizardForm.DirEdit.Text:= Copy(ListBox.Items[n],1,1) +Copy(WizardForm.DirEdit.Text, 2, Length(WizardForm.DirEdit.Text))
StartMenuTreeView: if StartMenuTreeView.Directory <> '' then WizardForm.GroupEdit.Text:= StartMenuTreeView.Directory else WizardForm.GroupEdit.Text:= '{#SetupSetting("DefaultGroupName")}'
WizardForm.NoIconsCheck: begin WizardForm.GroupEdit.Enabled:= not(WizardForm.GroupEdit.Enabled); StartMenuTreeView.Enabled:= WizardForm.GroupEdit.Enabled; WizardForm.GroupBrowseButton.Enabled:= WizardForm.GroupEdit.Enabled end;
end; End;

procedure InitializeWizard1();
begin
with WizardForm do begin
with MainPanel do
Height := Height - 1;
with WizardSmallBitmapImage do begin
Left := 0;
Top := 0;
Height := 58; //Размер рисунка
Width := 497; //
end;
with PageNameLabel do begin
Width := Width - 497; //Поставьте здесь значения на 0, если хотите вернуть текст
Left := Left + 497; //
end;
with PageDescriptionLabel do begin
Width := Width - 497; //Поставьте здесь значения на 0, если хотите вернуть текст
Left := Left + 497; //
end;
end;
end;

procedure InitializeWizard2();
begin
NeedSize := 2500; //Здесь указывается место для приложения
WizardForm.DiskSpaceLabel.Hide;
NeedSpaceLabel := TLabel.Create(WizardForm);
with NeedSpaceLabel do
begin
Parent := WizardForm.SelectDirPage;
Left := ScaleX(0);
Top := ScaleY(220);
Width := ScaleX(209);
Height := ScaleY(13);
end;
ListBox:= TListBox.Create(WizardForm)
ListBox.SetBounds(WizardForm.DirEdit.Left, WizardForm.DirEdit.Top + WizardForm.DirEdit.Height + 8, WizardForm.DirBrowseButton.Left + WizardForm.DirBrowseButton.Width - WizardForm.DirEdit.Left, WizardForm.DiskSpaceLabel.Top - (WizardForm.DirEdit.Top + WizardForm.DirEdit.Height + 12))
ListBox.Font.Size:= 9
ListBox.Font.Style:= []
ListBox.Font.Name:= 'Courier New';
ListBox.OnClick:= @ObjectOnClick;
ListBox.Parent:= WizardForm.SelectDirPage;
WizardForm.DirEdit.OnChange := @GetFreeSpaceCaption;
WizardForm.DirEdit.Text := WizardForm.DirEdit.Text + #0;
end;

procedure CurPageChanged1(CurPageID: Integer);
begin
if CurPageID=wpSelectDir then
begin
GetNeedSpaceCaption;
if FreeMB < NeedSize then
WizardForm.NextButton.Enabled:=False
ListBoxRefresh
end;
end;

procedure InitializeWizard3();
begin
WizardForm.TYPESCOMBO.Visible:= false;
WizardForm.ComponentsList.Height := WizardForm.ComponentsList.Height + WizardForm.ComponentsList.Top - WizardForm.TYPESCOMBO.Top;
WizardForm.ComponentsList.Top := WizardForm.TYPESCOMBO.Top;
WizardForm.ComponentsList.Width := ScaleX(200);
InfoPanel := TPanel.Create(WizardForm);
InfoPanel.Parent := WizardForm.SelectComponentsPage;
InfoPanel.Caption := '';
InfoPanel.Top := WizardForm.ComponentsList.Top;
InfoPanel.Left := ScaleX(216);
InfoPanel.Width := ScaleX(200);
InfoPanel.Height := WizardForm.ComponentsList.Height;
InfoPanel.BevelInner := bvRaised;
InfoPanel.BevelOuter := bvLowered;
InfoCaption := TNewStaticText.Create(WizardForm);
InfoCaption.Parent := WizardForm.SelectComponentsPage;
InfoCaption.Caption := 'Описание';
InfoCaption.Left := ScaleX(224);
InfoCaption.Top := InfoPanel.Top - ScaleY(5);
InfoCaption.Font.Color := clActiveCaption;
Info := TNewStaticText.Create(WizardForm);
Info.Parent := InfoPanel;
Info.AutoSize := False;
Info.Left := ScaleX(6);
Info.Width := ScaleX(188);
Info.Top := ScaleY(12);
Info.Height := WizardForm.ComponentsList.Height - ScaleY(18);
Info.Caption := 'Переместите ваш указатель мыши на компоненты чтобы увидеть их описание.';
Info.WordWrap := true;
//Впишыте описание компонентов
enabledesc(WizardForm.ComponentsList.Handle,Info.Handle,
'Выберите язык внутриигрового текста;'+ //Text
'Немецкий текст;'+
'Испанский текст;'+
'Французский текст;'+
'Итальянский текст;'+
'Польский текст;'+
'Выберите этот пункт, если вы хотите установить внутриигровую музыку. Учтите, что её можно отключить даже после инсталляции, в меню опций игры.;' // Music
);
end;



function ShouldSkipPage(CurPage: Integer): Boolean;
begin
if Pos('/SP-', UpperCase(GetCmdTail)) > 0 then
case CurPage of
wpLicense, wpPassword, wpInfoBefore, wpUserInfo,
wpSelectDir, wpSelectProgramGroup, wpInfoAfter:
Result := True;
end;
end;

const
WM_LBUTTONDOWN = 513;
WM_LBUTTONUP = 514;

procedure InitializeWizard4();
begin
if (Pos('/SP-', UpperCase(GetCmdTail)) > 0) then
begin
PostMessage(WizardForm.NextButton.Handle,WM_LBUTTONDOWN,0,0);
PostMessage(WizardForm.NextButton.Handle,WM_LBUTTONUP,0,0);
end;
end;

procedure CurPageChanged2(CurPageID: Integer);
begin
if (Pos('/SP-', UpperCase(GetCmdTail)) > 0) and
(CurPageID = wpSelectComponents) then
WizardForm.BackButton.Visible := False;
end;


//Проверка на оставшыеся файлы
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
var
Res: Integer;
begin
case CurUninstallStep of
usPostUninstall:
begin
if DirExists(ExpandConstant('{app}')) then
if ExpandConstant('{language}') = 'ua' then
case MsgBox('Папка "' + ExpandConstant('{app}') + '" не порожня.'#13#13 +
'"Так" – повне видалення всіх файлів у папці, включаючи саму папку.' #13#13 +
'"Ні" – відкрити папку в провіднику, щоб вручну видалити файли.'#13#13 +
'"Скасувати" – нічого не робити, видалити папку пізніше самостійно.', mbInformation, MB_YESNOCANCEL) of

IDYES:
if not DelTree(ExpandConstant('{app}'), True, True, True) then
MsgBox('Папка не видалена.' #13#13 'Папка або один з файлів у ній задіяні іншою програмою.', mbError, MB_OK);

IDNO:
if not ShellExec('open', ExpandConstant('{app}'), '', '', SW_SHOWMAXIMIZED, ewNoWait, Res) then
MsgBox('Помилка відкриття.' #13#13 'Папка не знайдена.', mbError, MB_OK);

IDCANCEL:;
end
else
if ExpandConstant('{language}') = 'ru' then
case MsgBox('Папка "' + ExpandConstant('{app}') + '" не пуста.'#13#13 +
'"Да" – полное удаление всех файлов в папке, включая саму папку.' #13#13 +
'"Нет" – открыть папку в проводнике, чтобы вручную удалить файлы.'#13#13 +
'"Отмена" – ничего не делать, удалить папку позже самостоятельно.', mbInformation, MB_YESNOCANCEL) of

IDYES:
if not DelTree(ExpandConstant('{app}'), True, True, True) then
MsgBox('Папка не удалена.' #13#13 'Папка или один из файлов в ней задействованы другим приложением.', mbError, MB_OK);

IDNO:
if not ShellExec('open', ExpandConstant('{app}'), '', '', SW_SHOWMAXIMIZED, ewNoWait, Res) then
MsgBox('Ошибка открытия.' #13#13 'Папка не найдена.', mbError, MB_OK);

IDCANCEL:;
end
else
case MsgBox('Directory "' + ExpandConstant('{app}') + '" is not empty.'#13#13 +
'"Yes" to delete all of the files in the directory, including the directory itself.' #13#13 +
'"No" to open the directory with explorer to delete the files manually.'#13#13 +
'"Cancel" to do nothing and delete the directory later manually.', mbInformation, MB_YESNOCANCEL) of

IDYES:
if not DelTree(ExpandConstant('{app}'), True, True, True) then
MsgBox('Directory is not deleted.' #13#13 'Directory or one of the files are used by the other application.', mbError, MB_OK);

IDNO:
if not ShellExec('open', ExpandConstant('{app}'), '', '', SW_SHOWMAXIMIZED, ewNoWait, Res) then
MsgBox('Error opening the directory.' #13#13 'Directory is not found.', mbError, MB_OK);

IDCANCEL:;
end
end
end
end;




const
n1=28; //количество слайдов
type
TProc = procedure(HandleW, msg, idEvent, TimeSys: LongWord);
TRandNumbers = array[1..N1] of byte;

function WrapTimerProc(callback:TProc; paramcount:integer):longword;
external 'wrapcallback@files:InnoCallback.dll stdcall';

function SetTimer(hWnd: LongWord; nIDEvent, uElapse: LongWord; lpTimerFunc: LongWord): LongWord;
external 'SetTimer@user32.dll stdcall';

function KillTimer(hWnd: LongWord; nIDEvent: LongWord): LongWord;
external 'KillTimer@user32.dll stdcall';

function get_unique_random_number(X:byte):TRandNumbers;
var
A,b,c: string;
i,j,k:byte;
begin
For i:=1 to X do A:=A+chr(i);
B:='';
For i:=1 to X do begin
j:=Random(Length(A)-1)+1;
C:='';
B:=B + A[j];
for k:=1 to Length(A) do
if k<>j then C:=C+A[k];
A:=C;
end;
for i:=1 to X do Result[i]:=ord(B[i]);
end;

var
TimerID: LongWord;
currTime: Integer;
SplashImage: TBitmapImage;
StatusMessages: TNewStaticText;
bmp: TRandNumbers;
z:byte;

procedure OnTimer(HandleW, msg, idEvent, TimeSys: LongWord);
begin
currTime := currTime + 1;
if (currTime mod {#TIME_FOR_VIEW} = 0)
then begin
SplashImage.Bitmap.LoadFromFile(ExpandConstant('{tmp}\Image_'+inttostr(bmp[currTime/{#TIME_FOR_VIEW}])+'.bmp'));
if (currTime/{#TIME_FOR_VIEW} = N1) then currTime:=0;
end;
end;


procedure InitializeWizard5;
begin
bmp:=get_unique_random_number(N1);
ExtractTemporaryFile('Image_'+inttostr(bmp[1])+'.bmp');

currTime := 0;

WizardForm.ProgressGauge.Parent := WizardForm;
WizardForm.ProgressGauge.Top := WizardForm.CancelButton.Top + ScaleY(12);
WizardForm.ProgressGauge.Left := ScaleX(10);
WizardForm.ProgressGauge.Width := WizardForm.MainPanel.Width - ScaleX(20);
WizardForm.ProgressGauge.Height := 16;
WizardForm.ProgressGauge.Hide;

WizardForm.StatusLabel.Parent := WizardForm;
WizardForm.StatusLabel.Top := WizardForm.ProgressGauge.Top - ScaleY(18);
WizardForm.StatusLabel.Left := ScaleX(10);
WizardForm.StatusLabel.Width := ScaleX(397);
WizardForm.StatusLabel.Hide;

SplashImage := TBitmapImage.Create(WizardForm);
SplashImage.Top := 0;
SplashImage.Left := 0;
SplashImage.Width := WizardForm.MainPanel.Width;
SplashImage.Height := WizardForm.Bevel.Top;
SplashImage.Parent := WizardForm.InnerPage;
SplashImage.Stretch := True;
SplashImage.Bitmap.LoadFromFile(ExpandConstant('{tmp}\Image_'+inttostr(bmp[1])+'.bmp'));
SplashImage.Hide;
end;

procedure CurStepChanged(CurStep: TSetupStep);
begin
if CurStep = ssInstall then
begin
WizardForm.StatusLabel.Caption := 'Распаковка слайдов...';
for z:=2 to N1 do ExtractTemporaryFile('Image_'+inttostr(bmp[z])+'.bmp');
end;
end;

procedure CurPageChanged3(CurPageID: Integer);
var
pfunc: LongWord;
begin
if (CurPageID = wpInstalling) then
begin
pfunc := WrapTimerProc(@OnTimer, 5);
TimerID := SetTimer(0, 0, 1000, pfunc);
WizardForm.PageNameLabel.Visible := False;
WizardForm.PageDescriptionLabel.Visible := False;
WizardForm.InnerNotebook.Hide;
WizardForm.Bevel1.Hide;
WizardForm.MainPanel.Hide;
WizardForm.PageNameLabel.Hide;
WizardForm.PageDescriptionLabel.Hide;
WizardForm.ProgressGauge.Show;
WizardForm.StatusLabel.Show;
SplashImage.Show;
WizardForm.CancelButton.Enabled := True;
WizardForm.CancelButton.Top := WizardForm.Bevel.Top + ScaleY(100);
end else
begin
WizardForm.ProgressGauge.Hide;
SplashImage.Hide;
WizardForm.FileNameLabel.Hide;
WizardForm.StatusLabel.Hide;
if (CurPageID > wpInstalling) and (CurPageID < wpFinished) then
begin
WizardForm.InnerNotebook.Show;
WizardForm.Bevel1.Show;
WizardForm.MainPanel.Show;
WizardForm.PageNameLabel.Show;
WizardForm.PageDescriptionLabel.Show;
end;
If CurPageID = wpFinished then
end;
end;


procedure CurPageChanged4(CurPageID: Integer);
begin
if CurPageID = wpInstalling then
WizardForm.BeveledLabel.hide;
if CurPageID = wpInfoAfter then
WizardForm.BeveledLabel.show;
end;




procedure InitializeWizard;
begin
InitializeWizard1();
InitializeWizard2();
InitializeWizard3();
InitializeWizard4();
InitializeWizard5();
end;


procedure CurPageChanged(CurPageID: Integer);
begin
CurPageChanged1(CurPageID);
CurPageChanged2(CurPageID);
CurPageChanged3(CurPageID);
CurPageChanged4(CurPageID);
end;

procedure DeinitializeSetup();
begin
disabledesc();
KillTimer(0, TimerID);
end;

El Sanchez
30-08-2011, 22:03
А касательно объединения кодов, ктонить помочь может? »
Raf-9600, только объединил, не проверял. Имхо укоротить код можно минимум на треть.


#define TIME_FOR_VIEW 10

[C0de]
const
n1=28; //количество слайдов
oneMB= 1024*1024;

type
TProc = procedure(HandleW, msg, idEvent, TimeSys: LongWord);
TRandNumbers = array[1..N1] of byte;

function GetLogicalDrives: DWord; external 'GetLogicalDrives@kernel32.dll stdcall';
function GetDriveType(nDrive: String): Longint; external 'GetDriveTypeA@kernel32.dll stdcall';
function GetVolumeInformation(PathName,VolumeName: PChar; VolumeNameSize,VolumeSerialNumber,MaxComponentLength,FileSystemFlags: Longint; FileSystemName: PChar; FileSystemNameSize: Longint): Longint; external 'GetVolumeInformationA@kernel32.dll stdcall';
function MessageBox(hWnd: Integer; lpText, lpCaption: String; uType: Cardinal): Integer; external 'MessageBoxA@user32.dll stdcall';

function WrapTimerProc(callback:TProc; paramcount:integer):longword;
external 'wrapcallback@files:InnoCallback.dll stdcall';

function SetTimer(hWnd: LongWord; nIDEvent, uElapse: LongWord; lpTimerFunc: LongWord): LongWord;
external 'SetTimer@user32.dll stdcall';

function KillTimer(hWnd: LongWord; nIDEvent: LongWord): LongWord;
external 'KillTimer@user32.dll stdcall';

function enabledesc(ComponentsListHandle: HWND; DescLabelHandle: HWND; DescStrings: PChar): BOOL; external 'enabledesc@files:descctrl.dll stdcall';

function disabledesc(): BOOL; external 'disabledesc@files:descctrl.dll stdcall';

var
Info, InfoCaption, StatusMessages: TNewStaticText;
InfoPanel: TPanel;

FreeMB, TotalMB: Cardinal;
NeedSpaceLabel: TLabel;
NeedSize, n, currTime: Integer;
VolumeName, FileSystemName, S: String;
VolumeSerialNo, MaxComponentLength, FileSystemFlags: Longint;
ListBox: TListBox;
StartMenuTreeView: TStartMenuFolderTreeView;

Files: Array of String;
TimerID: LongWord;
SplashImage: TBitmapImage;
bmp: TRandNumbers;
z:byte;

procedure ChangeCaption(str: string);
begin
WizardForm.StatusLabel.Caption:= str;
end;

Function StringToArray(Text, Cut: String): array of String; var i, k: Integer;
Begin
SetArrayLength(Result, 0); if Cut = '' then Cut:= #1310; //если шаблон пуст, считаем переводы строк
Repeat k:= Pos(Cut,Text);
if k = 1 then begin Delete(Text, 1, Length(Cut)); CONTINUE
end;
SetArrayLength(Result, GetArrayLength(Result) +1); i:= GetArrayLength(Result) -1;
if k = 0 then
Result[i]:=Text
else begin
Result[i]:= Copy(Text, 1, k -1); Delete(Text, 1, Length(Result[i]) + Length(Cut));
end;
Until Length(Text) * k = 0;
End;

procedure FindFiles(FromDir: String; Mask: String);
var FSR, DSR: TFindRec; FindResult: Boolean;
begin
FindResult:= FindFirst(AddBackslash(FromDir)+Mask, FSR)
while FindResult do begin
if FSR.Attributes and FILE_ATTRIBUTE_DIRECTORY = 0 then begin
S:= S + AddBackslash(fromDir) + FSR.Name +'|';
end;
FindResult:= FindNext(FSR);
end;
FindResult:= FindFirst(AddBackslash(FromDir)+ '*.*', DSR)
while FindResult do begin
if ((DSR.Attributes and FILE_ATTRIBUTE_DIRECTORY) = FILE_ATTRIBUTE_DIRECTORY) and not ((DSR.Name = '.') or (DSR.Name = '..')) then begin
FindFiles(AddBackSlash(FromDir)+DSR.Name, Mask)
end;
FindResult:= FindNext(DSR);
end;
FindClose(FSR); FindClose(DSR)
end;

procedure RecodeOgg;
var ResultCode: integer; CurFile: String;
begin
FindFiles(ExpandConstant('{app}'), '*.ogg') //Находим все файлы по маске, в выбранной папке
Files:= StringToArray(S, '|') //Переводим в массив
WizardForm.ProgressGauge.Max:= GetArrayLength(Files)-1; //Получаем кол-во файлов
WizardForm.ProgressGauge.Position:=0
for n:=(GetArrayLength(Files)-1) downto 0 do begin
CurFile:= Files[n]
StringChange(CurFile, AddBackslash(ExpandConstant('{app}')), '')
Exec(ExpandConstant('{app}\oggdec.exe'), '-Q '+AddQuotes(CurFile), '', SW_Hide, EwWaitUntilTerminated, ResultCode) //Для каждого файла запускаем декодер
DeleteFile(Files[n]) //Удаляем ненужный файл
WizardForm.FilenameLabel.Caption:= Files[n]; //Двигаем прогрессбар
WizardForm.ProgressGauge.Position:= WizardForm.ProgressGauge.Position +1;
end;
DeleteFile(ExpandConstant('{app}\oggdec.exe'))
end;

procedure GetFreeSpaceCaption(Sender: TObject);
var
Path: String;
begin
Path := ExtractFileDrive(WizardForm.DirEdit.Text);
GetSpaceOnDisk(Path, True, FreeMB, TotalMB);
if FreeMB < NeedSize then
WizardForm.NextButton.Enabled := False else
WizardForm.NextButton.Enabled := True; end;

procedure GetNeedSpaceCaption;
begin
if NeedSize > 1024 then
NeedSpaceLabel.Caption := 'Требуется как минимум '+ FloatToStr(round(NeedSize/1024*100)/100) + ' Гб свободного дискового пространства.' else
NeedSpaceLabel.Caption := 'Требуется как минимум '+ IntToStr(NeedSize)+ ' Мб свободного дискового пространства.';
end;


Function ByteOrTB(Bytes: Extended; noMB: Boolean): String; { Перевод числа в значение бт/Кб/Мб/Гб/Тб (до 3х знаков после запятой)}
Begin
if not noMB then Result:= FloatToStr(Int(Bytes)) +' Мб' else
if Bytes < 1024 then Result:= FloatToStr(Int(Bytes)) +' Бт' else
if Bytes/1024 < 1024 then Result:= FloatToStr(round((Bytes/1024)*10)/10) +' Кб' else
If Bytes/oneMB < 1024 then Result:= FloatToStr(round(Bytes/oneMB*100)/100) +' Мб' else
If Bytes/oneMB/1000 < 1024 then Result:= FloatToStr(round(Bytes/oneMB/1024*1000)/1000) +' Гб' else
Result:= FloatToStr(round(Bytes/oneMB/oneMB*1000)/1000) +' Тб'
StringChange(Result, ',', '.')
End;

Function DelSP(String: String): String; { Удаление начальных, конечных и повторных пробелов }
Begin while (Pos(' ', String) > 0) do Delete(String, Pos(' ', String), 1); Result:= Trim(String); End;

Function CutString(String: String; MaxLength: Longint): String; { Обрезать строку до заданного кол-ва символов}
Begin
if Length(String) > MaxLength then Result:= Copy(String, 1, 6) +'...'+ Copy(String, Length(String) - MaxLength +9, MaxLength)
else Result:= String;
End;

Procedure GetDiskInfo(Disk: String);
Begin
FileSystemName:= StringOfChar(' ', 32); VolumeName:= StringOfChar(' ', 256);
GetVolumeInformation(Disk, VolumeName, 255, VolumeSerialNo, MaxComponentLength, FileSystemFlags, FileSystemName, 31);
FileSystemName:= DelSp(FileSystemName); VolumeName:= DelSp(VolumeName); if VolumeName='' then VolumeName:='без метки';
End;

Procedure ListBoxRefresh; var FreeB, TotalB: Cardinal; Path, String: string; Begin
ListBox.Items.Clear
for n:= 1 to 31 do // диск 'А' пропустить
if (GetLogicalDrives and (1 shl n)) > 0 then
if (GetDriveType(Chr(ord('A') + n) +':\') = 2) or (GetDriveType(Chr(ord('A') + n) +':\') = 3) then
if GetSpaceOnDisk(Chr(ord('A') + n) +':\', True, FreeMB, TotalMB) then ListBox.Items.Add(Chr(ord('A') + n) +':');
for n:= 0 to ListBox.Items.Count -1 do begin
Path:= Copy(ListBox.Items[n],1,2) +'\' { если в накопителе нет диска, пропустить обновление }
if GetSpaceOnDisk(Path, False, FreeB, TotalB) and GetSpaceOnDisk(Path, True, FreeMB, TotalMB) then begin GetDiskInfo(Path);
if FreeB >= $7FFFFFFF then String:= PadL(ByteOrTB(FreeMB*oneMB, true),10) else String:= PadL(ByteOrTB(FreeB, true),10);
if TotalB >= $7FFFFFFF then begin TotalB:= TotalMB; FreeB:= FreeMB; String:= PadL(ByteOrTB(TotalMB*oneMB, true),11) +' всего -'+ String end else String:= PadL(ByteOrTB(TotalB, true),11) +' всего| '+ String;
ListBox.Items[n]:= Copy(Path,1,2) + String + PadL(FloatToStr(round(FreeB/TotalB*100)),3)+ '% своб|'+ PadL(FileSystemName,5)+ '| '+ CutString(VolumeName,9); end; end;
End;

Procedure ObjectOnClick(Sender: TObject); Begin
Case TObject(Sender) of
ListBox: for n:= 0 to ListBox.Items.Count-1 do if ListBox.Selected[n] then WizardForm.DirEdit.Text:= Copy(ListBox.Items[n],1,1) +Copy(WizardForm.DirEdit.Text, 2, Length(WizardForm.DirEdit.Text))
StartMenuTreeView: if StartMenuTreeView.Directory <> '' then WizardForm.GroupEdit.Text:= StartMenuTreeView.Directory else WizardForm.GroupEdit.Text:= '{#SetupSetting("DefaultGroupName")}'
WizardForm.NoIconsCheck: begin WizardForm.GroupEdit.Enabled:= not(WizardForm.GroupEdit.Enabled); StartMenuTreeView.Enabled:= WizardForm.GroupEdit.Enabled; WizardForm.GroupBrowseButton.Enabled:= WizardForm.GroupEdit.Enabled end;
end; End;

procedure InitializeWizard1();
begin
with WizardForm do begin
with MainPanel do
Height := Height - 1;
with WizardSmallBitmapImage do begin
Left := 0;
Top := 0;
Height := 58; //Размер рисунка
Width := 497; //
end;
with PageNameLabel do begin
Width := Width - 497; //Поставьте здесь значения на 0, если хотите вернуть текст
Left := Left + 497; //
end;
with PageDescriptionLabel do begin
Width := Width - 497; //Поставьте здесь значения на 0, если хотите вернуть текст
Left := Left + 497; //
end;
end;
end;

procedure InitializeWizard2();
begin
NeedSize := 2500; //Здесь указывается место для приложения
WizardForm.DiskSpaceLabel.Hide;
NeedSpaceLabel := TLabel.Create(WizardForm);
with NeedSpaceLabel do
begin
Parent := WizardForm.SelectDirPage;
Left := ScaleX(0);
Top := ScaleY(220);
Width := ScaleX(209);
Height := ScaleY(13);
end;
ListBox:= TListBox.Create(WizardForm)
ListBox.SetBounds(WizardForm.DirEdit.Left, WizardForm.DirEdit.Top + WizardForm.DirEdit.Height + 8, WizardForm.DirBrowseButton.Left + WizardForm.DirBrowseButton.Width - WizardForm.DirEdit.Left, WizardForm.DiskSpaceLabel.Top - (WizardForm.DirEdit.Top + WizardForm.DirEdit.Height + 12))
ListBox.Font.Size:= 9
ListBox.Font.Style:= []
ListBox.Font.Name:= 'Courier New';
ListBox.OnClick:= @ObjectOnClick;
ListBox.Parent:= WizardForm.SelectDirPage;
WizardForm.DirEdit.OnChange := @GetFreeSpaceCaption;
WizardForm.DirEdit.Text := WizardForm.DirEdit.Text + #0;
end;

procedure CurPageChanged1(CurPageID: Integer);
begin
if CurPageID=wpSelectDir then
begin
GetNeedSpaceCaption;
if FreeMB < NeedSize then
WizardForm.NextButton.Enabled:=False
ListBoxRefresh
end;
end;

procedure InitializeWizard3();
begin
WizardForm.TYPESCOMBO.Visible:= false;
WizardForm.ComponentsList.Height := WizardForm.ComponentsList.Height + WizardForm.ComponentsList.Top - WizardForm.TYPESCOMBO.Top;
WizardForm.ComponentsList.Top := WizardForm.TYPESCOMBO.Top;
WizardForm.ComponentsList.Width := ScaleX(200);
InfoPanel := TPanel.Create(WizardForm);
InfoPanel.Parent := WizardForm.SelectComponentsPage;
InfoPanel.Caption := '';
InfoPanel.Top := WizardForm.ComponentsList.Top;
InfoPanel.Left := ScaleX(216);
InfoPanel.Width := ScaleX(200);
InfoPanel.Height := WizardForm.ComponentsList.Height;
InfoPanel.BevelInner := bvRaised;
InfoPanel.BevelOuter := bvLowered;
InfoCaption := TNewStaticText.Create(WizardForm);
InfoCaption.Parent := WizardForm.SelectComponentsPage;
InfoCaption.Caption := 'Описание';
InfoCaption.Left := ScaleX(224);
InfoCaption.Top := InfoPanel.Top - ScaleY(5);
InfoCaption.Font.Color := clActiveCaption;
Info := TNewStaticText.Create(WizardForm);
Info.Parent := InfoPanel;
Info.AutoSize := False;
Info.Left := ScaleX(6);
Info.Width := ScaleX(188);
Info.Top := ScaleY(12);
Info.Height := WizardForm.ComponentsList.Height - ScaleY(18);
Info.Caption := 'Переместите ваш указатель мыши на компоненты чтобы увидеть их описание.';
Info.WordWrap := true;
//Впишыте описание компонентов
enabledesc(WizardForm.ComponentsList.Handle,Info.Handle,
'Выберите язык внутриигрового текста;'+ //Text
'Немецкий текст;'+
'Испанский текст;'+
'Французский текст;'+
'Итальянский текст;'+
'Польский текст;'+
'Выберите этот пункт, если вы хотите установить внутриигровую музыку. Учтите, что её можно отключить даже после инсталляции, в меню опций игры.;' // Music
);
end;



function ShouldSkipPage(CurPage: Integer): Boolean;
begin
if Pos('/SP-', UpperCase(GetCmdTail)) > 0 then
case CurPage of
wpLicense, wpPassword, wpInfoBefore, wpUserInfo,
wpSelectDir, wpSelectProgramGroup, wpInfoAfter:
Result := True;
end;
end;

const
WM_LBUTTONDOWN = 513;
WM_LBUTTONUP = 514;

procedure InitializeWizard4();
begin
if (Pos('/SP-', UpperCase(GetCmdTail)) > 0) then
begin
PostMessage(WizardForm.NextButton.Handle,WM_LBUTTONDOWN,0,0);
PostMessage(WizardForm.NextButton.Handle,WM_LBUTTONUP,0,0);
end;
end;

procedure CurPageChanged2(CurPageID: Integer);
begin
if (Pos('/SP-', UpperCase(GetCmdTail)) > 0) and
(CurPageID = wpSelectComponents) then
WizardForm.BackButton.Visible := False;
end;


//Проверка на оставшыеся файлы
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
var
Res: Integer;
begin
case CurUninstallStep of
usPostUninstall:
begin
if DirExists(ExpandConstant('{app}')) then
if ExpandConstant('{language}') = 'ua' then
case MsgBox('Папка "' + ExpandConstant('{app}') + '" не порожня.'#13#13 +
'"Так" – повне видалення всіх файлів у папці, включаючи саму папку.' #13#13 +
'"Ні" – відкрити папку в провіднику, щоб вручну видалити файли.'#13#13 +
'"Скасувати" – нічого не робити, видалити папку пізніше самостійно.', mbInformation, MB_YESNOCANCEL) of

IDYES:
if not DelTree(ExpandConstant('{app}'), True, True, True) then
MsgBox('Папка не видалена.' #13#13 'Папка або один з файлів у ній задіяні іншою програмою.', mbError, MB_OK);

IDNO:
if not ShellExec('open', ExpandConstant('{app}'), '', '', SW_SHOWMAXIMIZED, ewNoWait, Res) then
MsgBox('Помилка відкриття.' #13#13 'Папка не знайдена.', mbError, MB_OK);

IDCANCEL:;
end
else
if ExpandConstant('{language}') = 'ru' then
case MsgBox('Папка "' + ExpandConstant('{app}') + '" не пуста.'#13#13 +
'"Да" – полное удаление всех файлов в папке, включая саму папку.' #13#13 +
'"Нет" – открыть папку в проводнике, чтобы вручную удалить файлы.'#13#13 +
'"Отмена" – ничего не делать, удалить папку позже самостоятельно.', mbInformation, MB_YESNOCANCEL) of

IDYES:
if not DelTree(ExpandConstant('{app}'), True, True, True) then
MsgBox('Папка не удалена.' #13#13 'Папка или один из файлов в ней задействованы другим приложением.', mbError, MB_OK);

IDNO:
if not ShellExec('open', ExpandConstant('{app}'), '', '', SW_SHOWMAXIMIZED, ewNoWait, Res) then
MsgBox('Ошибка открытия.' #13#13 'Папка не найдена.', mbError, MB_OK);

IDCANCEL:;
end
else
case MsgBox('Directory "' + ExpandConstant('{app}') + '" is not empty.'#13#13 +
'"Yes" to delete all of the files in the directory, including the directory itself.' #13#13 +
'"No" to open the directory with explorer to delete the files manually.'#13#13 +
'"Cancel" to do nothing and delete the directory later manually.', mbInformation, MB_YESNOCANCEL) of

IDYES:
if not DelTree(ExpandConstant('{app}'), True, True, True) then
MsgBox('Directory is not deleted.' #13#13 'Directory or one of the files are used by the other application.', mbError, MB_OK);

IDNO:
if not ShellExec('open', ExpandConstant('{app}'), '', '', SW_SHOWMAXIMIZED, ewNoWait, Res) then
MsgBox('Error opening the directory.' #13#13 'Directory is not found.', mbError, MB_OK);

IDCANCEL:;
end
end
end
end;


function get_unique_random_number(X:byte):TRandNumbers;
var
A,b,c: string;
i,j,k:byte;
begin
For i:=1 to X do A:=A+chr(i);
B:='';
For i:=1 to X do begin
j:=Random(Length(A)-1)+1;
C:='';
B:=B + A[j];
for k:=1 to Length(A) do
if k<>j then C:=C+A[k];
A:=C;
end;
for i:=1 to X do Result[i]:=ord(B[i]);
end;

procedure OnTimer(HandleW, msg, idEvent, TimeSys: LongWord);
begin
currTime := currTime + 1;
if (currTime mod {#TIME_FOR_VIEW} = 0)
then begin
SplashImage.Bitmap.LoadFromFile(ExpandConstant('{tmp}\Image_'+inttostr(bmp[currTime/{#TIME_FOR_VIEW}])+'.bmp'));
if (currTime/{#TIME_FOR_VIEW} = N1) then currTime:=0;
end;
end;


procedure InitializeWizard5;
begin
bmp:=get_unique_random_number(N1);
ExtractTemporaryFile('Image_'+inttostr(bmp[1])+'.bmp');

currTime := 0;

WizardForm.ProgressGauge.Parent := WizardForm;
WizardForm.ProgressGauge.Top := WizardForm.CancelButton.Top + ScaleY(12);
WizardForm.ProgressGauge.Left := ScaleX(10);
WizardForm.ProgressGauge.Width := WizardForm.MainPanel.Width - ScaleX(20);
WizardForm.ProgressGauge.Height := 16;
WizardForm.ProgressGauge.Hide;

WizardForm.StatusLabel.Parent := WizardForm;
WizardForm.StatusLabel.Top := WizardForm.ProgressGauge.Top - ScaleY(18);
WizardForm.StatusLabel.Left := ScaleX(10);
WizardForm.StatusLabel.Width := ScaleX(397);
WizardForm.StatusLabel.Hide;

SplashImage := TBitmapImage.Create(WizardForm);
SplashImage.Top := 0;
SplashImage.Left := 0;
SplashImage.Width := WizardForm.MainPanel.Width;
SplashImage.Height := WizardForm.Bevel.Top;
SplashImage.Parent := WizardForm.InnerPage;
SplashImage.Stretch := True;
SplashImage.Bitmap.LoadFromFile(ExpandConstant('{tmp}\Image_'+inttostr(bmp[1])+'.bmp'));
SplashImage.Hide;
end;

procedure CurStepChanged(CurStep: TSetupStep);
begin
if CurStep = ssInstall then
begin
WizardForm.StatusLabel.Caption := 'Распаковка слайдов...';
for z:=2 to N1 do ExtractTemporaryFile('Image_'+inttostr(bmp[z])+'.bmp');
end;
if CurStep = ssPostInstall then begin
if (IsComponentSelected('VoiceD2') and IsComponentSelected('VoiceLoD') ) then begin
ChangeCaption('Конвертация ogg, иди покури');
RecodeOgg;
end; //if IsComponentSelected
end; //CurStep = ssPostInstall
end;

procedure CurPageChanged3(CurPageID: Integer);
var
pfunc: LongWord;
begin
if (CurPageID = wpInstalling) then
begin
pfunc := WrapTimerProc(@OnTimer, 5);
TimerID := SetTimer(0, 0, 1000, pfunc);
WizardForm.PageNameLabel.Visible := False;
WizardForm.PageDescriptionLabel.Visible := False;
WizardForm.InnerNotebook.Hide;
WizardForm.Bevel1.Hide;
WizardForm.MainPanel.Hide;
WizardForm.PageNameLabel.Hide;
WizardForm.PageDescriptionLabel.Hide;
WizardForm.ProgressGauge.Show;
WizardForm.StatusLabel.Show;
SplashImage.Show;
WizardForm.CancelButton.Enabled := True;
WizardForm.CancelButton.Top := WizardForm.Bevel.Top + ScaleY(100);
end else
begin
WizardForm.ProgressGauge.Hide;
SplashImage.Hide;
WizardForm.FileNameLabel.Hide;
WizardForm.StatusLabel.Hide;
if (CurPageID > wpInstalling) and (CurPageID < wpFinished) then
begin
WizardForm.InnerNotebook.Show;
WizardForm.Bevel1.Show;
WizardForm.MainPanel.Show;
WizardForm.PageNameLabel.Show;
WizardForm.PageDescriptionLabel.Show;
end;
If CurPageID = wpFinished then
end;
end;


procedure CurPageChanged4(CurPageID: Integer);
begin
if CurPageID = wpInstalling then
WizardForm.BeveledLabel.hide;
if CurPageID = wpInfoAfter then
WizardForm.BeveledLabel.show;
end;




procedure InitializeWizard;
begin
InitializeWizard1();
InitializeWizard2();
InitializeWizard3();
InitializeWizard4();
InitializeWizard5();
end;


procedure CurPageChanged(CurPageID: Integer);
begin
CurPageChanged1(CurPageID);
CurPageChanged2(CurPageID);
CurPageChanged3(CurPageID);
CurPageChanged4(CurPageID);
end;

procedure DeinitializeSetup();
begin
disabledesc();
KillTimer(0, TimerID);

Mafia_forever
30-08-2011, 22:13
как сделать чтобы при выборе компонентов установки он создавал папку и распаковывался туда
например отметить скажем sound.mp3 в выборочой установке и во время установки инстлятор должен создать папку mp3 и распаковать его туда

Raf-9600
30-08-2011, 22:33
El Sanchez, Превосходно! Спасибо огромное! http://i25.fastpic.ru/big/2011/0725/ac/bae6b5acb4bc439f5ddf6c309166bcac.gif

А касательно длинны кода - знаю. Возможно из-за лишних строчек, инсталы созданные с ним, так тормозят. Но мне знаний не хватает его "почистить". Если для Вас не сложно, был бы весьма признателен, если вы уделите свое время этой проблеме. Но я не настаиваю, Вы и так мне очень помогли. http://www.kolobok.us/smiles/light_skin/good3.gif

Habetdin
31-08-2011, 00:01
Mafia_forever, пример:
[Components]
Name: unpack; Description: "Распаковать sound.mp3 в папку mp3"

[Files]
Source: Files\mp3\sound.mp3; DestDir: {app}\mp3; Components: unpack; Flags: ignoreversion

З.Ы.: чтение справки творит чудеса ;)

Raf-9600
31-08-2011, 00:19
Ктонить встречался с кодом\dll'кой isProgressBar (http://rghost.ru/2304090) от ExpeditorR, для создания "технического" прогресс-бара? Как я понял, он создает отдельную страницу с собственным прогресс-баром. А можно ли сделать так, чтоб его прогресс-бар отображался поверх\вместо стандартного, на стандартной странице инсталляции?

Sollar
31-08-2011, 11:34
El Sanchez, как заставить срабатывать процедуру после клика по определенному объекту? потому что только после второго клика она работала
вот вопрос, а задачу я сделал по-другому, теперь мне интересно на будущее

и еще, можно ли в зависимых задачах писать разные groupdescription? если нет, то как это обойти? возможно ли такое?

Mafia_forever
31-08-2011, 16:29
как сделть чтоб интлятор во время установки сам определил папку установки

Наприmер GTA San Andreas Usef Files

а если выбранна другая папка выходило сообщение
что не верная папка

Habetdin
31-08-2011, 18:48
Mafia_forever, имя папки задано, страница выбора места установки отключена:
[Setup]
DisableDirPage=yes
DefaultDirName={pf}\Fixed Folder Name

Kizekil
01-09-2011, 18:21
Здравствуйте!!! :) Можно задать вам пару вопросиков?Скажите пожалуйста как поменять цвет шрифта (там код какой то) .Как сделать чтоб отображалось время установки (без архивов и FreeArc,скачивал ISDone не помогло,можно код? :blush2: )?. Зделать изображение на весь экран (только страница привествия) .Смотрел ваши комменты и видно что вы разбираетесь в инно сетуп :) .Надеюсь ответите!!!С уважением,Kizekil!!!

insombia
01-09-2011, 21:11
Kizekil Как сделать чтоб отображалось время установки (без архивов и FreeArc,скачивал ISDone не помогло,можно код?

[CustomMessages]
rus.hour= часов
rus.min= мин
rus.sec= сек

[code]
type
TTimerProc = procedure(HandleW, Msg, idEvent, TimeSys: LongWord);

var
StartInstall: Integer;
TimeLabel: TLabel;
TimerID: Longword;

function GetTickCount: DWord; external 'GetTickCount@kernel32';
function WrapTimerProc(callback: TTimerProc; Paramcount: Integer): longword; external 'wrapcallback@files:innocallback.dll stdcall';
function SetTimer(hWnd, nIDEvent, uElapse, lpTimerFunc: LongWord): longword; external 'SetTimer@user32';
function KillTimer(hWnd, nIDEvent: LongWord): LongWord; external 'KillTimer@user32 stdcall delayload';

Function cm(Message: String): String; Begin Result:= ExpandConstant('{cm:'+ Message +'}') End;

Function TicksToTime(Ticks: DWord; h,m,s: String; detail: Boolean): String;
Begin
if detail then {hh: mm:ss format}
Result:= PADZ(IntToStr(Ticks/3600000), 2) +':'+ PADZ(IntToStr((Ticks/1000 - Ticks/1000/3600*3600)/60), 2) +':'+ PADZ(IntToStr(Ticks/1000 - Ticks/1000/60*60), 2)
else if Ticks/3600 >= 1000 then {more than hour}
Result:= IntToStr(Ticks/3600000) +h+' '+ PADZ(IntToStr((Ticks/1000 - Ticks/1000/3600*3600)/60), 2) +m
else if Ticks/60 >= 1000 then {1..60 minutes}
Result:= IntToStr(Ticks/60000) +m+' '+ IntToStr(Ticks/1000 - Ticks/1000/60*60) +s
else Result:= Format('%.1n', [Abs(Ticks/1000)]) +s {less than one minute}
End;

procedure GetTime(HandleW, Msg, idEvent, TimeSys: LongWord);
var Remaining: Integer;
begin
with WizardForm.ProgressGauge do begin
if position > 0 then Remaining:= trunc((GetTickCount - StartInstall) * Abs((max - position)/position))
TimeLabel.Caption:= 'Осталось ждать: ' + TicksToTime(Remaining, cm('hour'), cm('min'), cm('sec'), false)
if (Remaining = 0) then TimeLabel.Caption:= 'Завершение...'
end;
end;

procedure InitializeWizard();
begin
TimeLabel:= TLabel.Create(WizardForm)
TimeLabel.SetBounds(ScaleX(0), ScaleY(80), ScaleX(457), ScaleY(20));
TimeLabel.AutoSize:= False
TimeLabel.Transparent:= True;
TimeLabel.Parent:= WizardForm.InstallingPage;
end;

procedure CurStepChanged(CurStep: TSetupStep);
begin
If CurStep = ssInstall then
begin
StartInstall:= GetTickCount
TimerID:= SetTimer(0,0, 500, WrapTimerProc(@GetTime, 4))
end;
end;

procedure DeinitializeSetup();
begin
KillTimer(0, TimerID)
end;

Kizekil
02-09-2011, 16:11
Как сделать чтоб была установка direct x и других нужных вещей?И как поставить изображение на всё окно инсталлятора (только на странице привествия)?

Mafia_forever
02-09-2011, 18:57
Как сделать чтоб отображалось время установки (без архивов и FreeArc,скачивал ISDone не помогло,можно код? »

[Name]
Name: rus; Name: compiler:Name\Russian.isl

[CustomMessages]
rus.hour= часов
rus.min= мин
rus.sec= сек

Source: compiler:innocallback.dll; DestDir: {tmp}; Flags: dontcopy;

[code]
type
TTimerProc = procedure(HandleW, Msg, idEvent, TimeSys: LongWord);

var
StartInstall: Integer;
TimeLabel: TLabel;
TimerID: Longword;

function GetTickCount: DWord; external 'GetTickCount@kernel32';
function WrapTimerProc(callback: TTimerProc; Paramcount: Integer): longword; external 'wrapcallback@files:innocallback.dll stdcall';
function SetTimer(hWnd, nIDEvent, uElapse, lpTimerFunc: LongWord): longword; external 'SetTimer@user32';
function KillTimer(hWnd, nIDEvent: LongWord): LongWord; external 'KillTimer@user32 stdcall delayload';

Function cm(Message: String): String; Begin Result:= ExpandConstant('{cm:'+ Message +'}') End;

Function TicksToTime(Ticks: DWord; h,m,s: String; detail: Boolean): String;
Begin
if detail then {hh: mm:ss format}
Result:= PADZ(IntToStr(Ticks/3600000), 2) +':'+ PADZ(IntToStr((Ticks/1000 - Ticks/1000/3600*3600)/60), 2) +':'+ PADZ(IntToStr(Ticks/1000 - Ticks/1000/60*60), 2)
else if Ticks/3600 >= 1000 then {more than hour}
Result:= IntToStr(Ticks/3600000) +h+' '+ PADZ(IntToStr((Ticks/1000 - Ticks/1000/3600*3600)/60), 2) +m
else if Ticks/60 >= 1000 then {1..60 minutes}
Result:= IntToStr(Ticks/60000) +m+' '+ IntToStr(Ticks/1000 - Ticks/1000/60*60) +s
else Result:= Format('%.1n', [Abs(Ticks/1000)]) +s {less than one minute}
End;

procedure GetTime(HandleW, Msg, idEvent, TimeSys: LongWord);
var Remaining: Integer;
begin
with WizardForm.ProgressGauge do begin
if position > 0 then Remaining:= trunc((GetTickCount - StartInstall) * Abs((max - position)/position))
TimeLabel.Caption:= 'Осталось ' + TicksToTime(Remaining, cm('hour'), cm('min'), cm('sec'), false)
if (Remaining = 0) then TimeLabel.Caption:= 'Завершение...'
end;
end;

procedure InitializeWizard();
begin
TimeLabel:= TLabel.Create(WizardForm)
TimeLabel.SetBounds(ScaleX(0), ScaleY(80), ScaleX(457), ScaleY(20));
TimeLabel.AutoSize:= False
TimeLabel.Transparent:= True;
TimeLabel.Parent:= WizardForm.InstallingPage;
end;

procedure CurStepChanged(CurStep: TSetupStep);
begin
If CurStep = ssInstall then
begin
StartInstall:= GetTickCount
TimerID:= SetTimer(0,0, 500, WrapTimerProc(@GetTime, 4))
end;
end;

procedure DeinitializeSetup();
begin
KillTimer(0, TimerID)
end;

Как сделать чтоб была установка direct x и других нужных вещей »

[Setup]
ShowTasksTreeLines=true

[Tasks]
Name: additional; Description: "Дополнительные компоненты";
Name: additional\dx; Description: "Обновить DirectX";
Name: additional\vcr; Description: "Обновить Visual C++";

[Run]
Filename: {src}\Redist\DirectX.exe; Tasks: additional\dx; Parameters: /silent; StatusMsg: Обновление DirectX...
Filename: {src}\Redist\MS Visual C++ 2005 SP1.exe; Tasks: additional\vcr; Parameters: /q; StatusMsg: Обновление Visual C++...

И как поставить изображение на всё окно инсталлятора (только на странице привествия)? »

[Files]
Source: "C:\Program Files\Inno Setup 5\Img2.bmp"; DestDir: {tmp}; Flags: dontcopy

[code]

var
WelcomeLabel1, WelcomeLabel2, FinishedLabel, FinishedHeadingLabel: TLabel;

procedure InitializeWizard();
begin
ExtractTemporaryFile('img2.bmp');

WizardForm.WizardBitmapImage.Width:= ScaleX(497);
WizardForm.WizardBitmapImage2.Width:= ScaleX(497);
WizardForm.WizardBitmapImage2.Bitmap.LoadFromFile(ExpandConstant('{tmp}\img2.bmp'));

WelcomeLabel1:= TLabel.Create(WizardForm);
WelcomeLabel1.AutoSize:= False;
with WizardForm.WelcomeLabel1 do
WelcomeLabel1.SetBounds(Left, Top, Width, Height);
WelcomeLabel1.Font:= WizardForm.WelcomeLabel1.Font
WelcomeLabel1.Font.Color:= clyellow;
WelcomeLabel1.Transparent:= True;
WelcomeLabel1.WordWrap:= true;
WelcomeLabel1.Caption:= WizardForm.WelcomeLabel1.Caption;
WelcomeLabel1.Parent:= WizardForm.WelcomePage

WelcomeLabel2:= TLabel.Create(WizardForm);
WelcomeLabel2.AutoSize:= False;
with WizardForm.WelcomeLabel2 do
WelcomeLabel2.SetBounds(Left, Top, Width, Height);
WelcomeLabel2.Font:= WizardForm.WelcomeLabel2.Font
WelcomeLabel2.Font.Color:= clblue;
WelcomeLabel2.Transparent:= True;
WelcomeLabel2.WordWrap:= true;
WelcomeLabel2.Caption:= WizardForm.WelcomeLabel2.Caption;
WelcomeLabel2.Parent:= WizardForm.WelcomePage

FinishedHeadingLabel:= TLabel.Create(WizardForm);
FinishedHeadingLabel.AutoSize:= False;
with WizardForm.FinishedHeadingLabel do
FinishedHeadingLabel.SetBounds(Left, Top, Width, Height);
FinishedHeadingLabel.Font:= WizardForm.FinishedHeadingLabel.Font
FinishedHeadingLabel.Font.Color:= clRed;
FinishedHeadingLabel.Transparent:= True;
FinishedHeadingLabel.WordWrap:= true;
FinishedHeadingLabel.Caption:= WizardForm.FinishedHeadingLabel.Caption;
FinishedHeadingLabel.Parent:= WizardForm.FinishedPage

FinishedLabel:= TLabel.Create(WizardForm);
FinishedLabel.AutoSize:= False;
with WizardForm.FinishedLabel do
FinishedLabel.SetBounds(Left, Top, Width, Height);
FinishedLabel.Font:= WizardForm.FinishedLabel.Font
FinishedLabel.Font.Color:= clyellow;
FinishedLabel.Transparent:= True;
FinishedLabel.WordWrap:= true;
FinishedLabel.Caption:= WizardForm.FinishedLabel.Caption;
FinishedLabel.Parent:= WizardForm.FinishedPage

WizardForm.WelcomeLabel1.Hide;
WizardForm.WelcomeLabel2.Hide;
WizardForm.FinishedLabel.Hide;
WizardForm.FinishedHeadingLabel.Hide;
WizardForm.Position:=poScreenCenter;
end;

procedure CurPageChanged(CurPageID: Integer);
begin
FinishedLabel.Caption:= WizardForm.FinishedLabel.Caption;
end;

insombia будь добр дай код для music button.png а то мой не работает

const
BASS_ACTIVE_PLAYING = 1;
BASS_ACTIVE_STALLED = 2;
BASS_ACTIVE_PAUSED = 3;
BASS_SAMPLE_LOOP = 4;
var
MusicButton1,MusicButton2,mp3Handle: HWND;
mp3Name: String;

function sndPlaySound(lpszSoundName: String; uFlags: cardinal):integer; external 'sndPlaySound{#A}@winmm.dll stdcall';
function BASS_Init(device: Integer; freq, flags: DWORD; win: hwnd; CLSID: Integer): Boolean; external 'BASS_Init@files:BASS.dll stdcall delayload';
function BASS_StreamCreateFile(mem: BOOL; f: PChar; offset: DWORD; length: DWORD; flags: DWORD): DWORD; external 'BASS_StreamCreateFile@files:BASS.dll stdcall delayload';
function BASS_Start(): Boolean; external 'BASS_Start@files:BASS.dll stdcall delayload';
function BASS_ChannelPlay(handle: DWORD; restart: BOOL): Boolean; external 'BASS_ChannelPlay@files:BASS.dll stdcall delayload';
function BASS_ChannelIsActive(handle: DWORD): Integer; external 'BASS_ChannelIsActive@files:BASS.dll stdcall delayload';
function BASS_ChannelPause(handle: DWORD): Boolean; external 'BASS_ChannelPause@files:BASS.dll stdcall delayload';
function BASS_Pause(): Boolean; external 'BASS_Pause@files:BASS.dll stdcall delayload';
function BASS_Stop(): Boolean; external 'BASS_Stop@files:BASS.dll stdcall delayload';
function BASS_Free(): Boolean; external 'BASS_Free@files:BASS.dll stdcall delayload';

function InitializeSetup:boolean;
begin
if not FileExists(ExpandConstant('{tmp}\botva2.dll')) then ExtractTemporaryFile('botva2.dll');
if not FileExists(ExpandConstant('{tmp}\CallbackCtrl.dll')) then ExtractTemporaryFile('CallbackCtrl.dll');
Result:=True;
end;

procedure WFBtnEnter(hBtn:HWND);
begin
sndPlaySound(ExpandConstant('{tmp}\WFEnter.wav'), $0001);
end;

procedure MusicButtonClick(hBtn:HWND);
begin
sndPlaySound(ExpandConstant('{tmp}\Click.wav'), $0001);
if BtnGetChecked(hBtn) then begin


BASS_ChannelPause(mp3Handle);
end else
case BASS_ChannelIsActive(mp3Handle) of
BASS_ACTIVE_PAUSED:
begin
BASS_ChannelPlay(mp3Handle, False);
end;
end;
btnSetChecked(MusicButton1, BtnGetChecked(hBtn))
btnSetChecked(MusicButton2, BtnGetChecked(hBtn))
end;


procedure InsertMusic;
begin
ExtractTemporaryFile('MusicButton.png');
ExtractTemporaryFile('BASS.dll');
ExtractTemporaryFile('Music.mp3');
ExtractTemporaryFile('Click.wav');
ExtractTemporaryFile('Check.wav');
ExtractTemporaryFile('WFEnter.wav');


MusicButton1:=BtnCreate(WizardForm.WelcomePage.Handle,ScaleX(20),ScaleY(20),ScaleX(25),ScaleY(23),Ex pandConstant('{tmp}\MusicButton.png'),0,True);

BtnSetEvent(MusicButton1,BtnClickEventID,WrapBtnCallback(@MusicButtonClick,1));
BtnSetEvent(MusicButton1,BtnMouseEnterEventID,WrapBtnCallback(@WFBtnEnter,1));
BtnSetVisibility(MusicButton1,True);
BtnSetCursor(MusicButton1,GetSysCursorHandle(32649));
ImgApplyChanges(WizardForm.WelcomePage.Handle);




MusicButton2:=BtnCreate(WizardForm.SelectDirPage.Handle,ScaleX(20),ScaleY(20),ScaleX(25),ScaleY(23), ExpandConstant('{tmp}\MusicButton.png'),0,True);
BtnSetEvent(MusicButton2,BtnClickEventID,WrapBtnCallback(@MusicButtonClick,1));
BtnSetEvent(MusicButton2,BtnMouseEnterEventID,WrapBtnCallback(@WFBtnEnter,1));
BtnSetVisibility(MusicButton2,True);
BtnSetCursor(MusicButton2,GetSysCursorHandle(32649));
ImgApplyChanges(WizardForm.SelectDirPage.Handle);

mp3Name := ExpandConstant('{tmp}\Music.mp3');
BASS_Init(-1, 44100, 0, 0, 0);
mp3Handle := BASS_StreamCreateFile(FALSE, PChar(mp3Name), 0, 0, BASS_SAMPLE_LOOP);
BASS_Start();
BASS_ChannelPlay(mp3Handle, False);
end;

//************************************************ [Конец - Музыка] ***************************************************//

procedure InitializeWizard;
begin
InsertMusic;
end;

procedure CurPageChanged(CurPageID: Integer);
begin
ImgApplyChanges(WizardForm.Handle);
end;


procedure DeinitializeSetup();
begin
BASS_Stop();
BASS_Free();
gdipShutdown;
end;

Rikill
03-09-2011, 02:52
Mafia_forever, ты мемуары свои под спойлер спряч!




© OSzone.net 2001-2012