Ru-Board.club
← Вернуться в раздел «Программы»

» Inno Setup (создание инсталяционных пакетов)

Автор: Shegorat
Дата сообщения: 06.08.2010 14:38
greggh

Цитата:
1) Можно примерно узнать, что было в секции код или восстановить ее или же нужно учить Delphi и самому батцать код?

Восстановить секцию code из инсталятора нельзя. Нужно смотреть что этот инсталятор делает и исходя из наблюдений писать самому всю секцию code.

Цитата:
2) Как перепаковываются программы уже запакованные в inno setup, если исчезает секция код? К примеру, мне нужно чтобы программа не задавала вопросов во время установки, удалить лишние языковые пакеты, убрать всякие линки на офф. сайт и тому подобное, думаю общие мысли я изложил.

В большинстве случаев в инсталяторах присутствует секция компонентов. Если не ошибаюсь, то isunpacker восстанавливает секцию компонентов. В восстановленном скрипте можно посмотреть какие файлы к каким компонентом привязаны. Если же зависимость установки файлов указана в секции code, то тут придется вручную выяснять зависимости.
А чтобы программа не задавала вопросов при установке нужно или эти запросы убрать в скрипте или запускать с ключом /SILENT

P.S Кто хочет помочь в локализации скрипта FreeArcExtract+DiskPromts на другие языки, прошу в личку
Автор: SotM
Дата сообщения: 06.08.2010 14:42
greggh
1. Ты уже сам ответил на этот вопрос. Секцию code тебе придется писать с нуля. При распаковке она отсутствует На самом деле она присутствует, но в псевдоассемблерном виде, что для простых людей является нечитабельным.
2. Изучаешь разные примеры скриптов и переделываешь под себя. И тогда уже твоя программа не будет задавать глупых вопросов, будет ставить нужные ТЕБЕ языковые пакеты и т.д.

В шапке есть куча разных скриптов.
Автор: StalkMent
Дата сообщения: 06.08.2010 14:44

Цитата:
А ты скачай все оффлайн версии и поищи в них.

Ну поискал и не нашёл, потому что программе трудно объяснить что мне нужно)


Пожалуйста помогите мне
Автор: JohnDes
Дата сообщения: 06.08.2010 14:44
greggh

Цитата:
1) Можно примерно узнать, что было в секции код или восстановить ее

2) Как перепаковываются программы уже запакованные в inno setup, если исчезает секция код?

3)К примеру, мне нужно чтобы программа не задавала вопросов во время установки, удалить лишние языковые пакеты, убрать всякие линки на офф. сайт и тому подобное...

1) Насколько знаю я, это невозможно.

2) Программа распаковывается unpacker`ом, в полученном iss коде просматривают файлы, которые используются, если в них есть те которые отвечают за выполнения кода, находят исходники, и их редактируют под себя.

3)В своем скрипте просто не пишешь эти функции...

Думаю я внятно объяснил.
Автор: TonyJef
Дата сообщения: 06.08.2010 14:59
JohnDes,уверен? я в отличии от тебя знаю что и как,мне всего лишь нужно узнать скрипт авторана для антологии!!!
Автор: frionsx
Дата сообщения: 06.08.2010 15:01
Подскажите как сделать такую же страницу приветствия как сдесь

заранее спасибо
Автор: JohnDes
Дата сообщения: 06.08.2010 15:07
TonyJef

Цитата:
уверен? я в отличии от тебя знаю что и как,мне всего лишь нужно узнать скрипт авторана для антологии!!!

Уверен на все 100%
Вот тебе скрипт авто рана
[more]
[Setup]
AppName=AutoRUN
VersionInfoDescription=AutoRUN
VersionInfoProductName=AutoRUN
AppVerName=AutoRUN
VersionInfoProductVersion=1.0.0.0
VersionInfoVersion=1.0.0.0
VersionInfoCompany=john
VersionInfoCopyright=Copyright © John
CreateAppDir=no
OutputDir=.
OutputBaseFilename=Autorun
SetupIconFile=Icon.ico

[Languages]
Name: Russian; MessagesFile: compiler:Default.isl

[Files]
Source: 1.bmp; Flags: dontcopy

[Messages]
SetupAppTitle=AutoRUN

[Code]
const
BM_CLICK = $00F5;

var
AutoRun: TSetupForm;
img1: TBitmapImage;
PlayButton, InstallButton, SupportButton, ReadmeButton, WebButton, ExitButton, UninstallButton: TButton;
AppPath,UninsPath: string;
ResultCode: Integer;
procedure CurPageChanged(CurPageID: Integer);
begin
If CurPageID=wpWelcome then
SendMessage(WizardForm.NextButton.Handle, BM_CLICK, 0, 0);
end;

procedure CancelButtonClick(CurPageID: Integer; var Cancel, Confirm: Boolean);
begin
Confirm:=False
Cancel:=True
end;

procedure PlayButtonClick(Sender: TObject);
var
exe: string;
begin
exe:='shift.exe';
if RegQueryStringValue(HKLM, 'SOFTWARE\Electronic Arts\Game','Install Dir', AppPath) then
begin
Exec(AddBackslash(AppPath) + Exe, '', ExtractFilePath(AddBackslash(AppPath) + Exe), SW_SHOWNORMAL,ewNoWait,ResultCode)
AutoRun.Close;
PostMessage(WizardForm.CancelButton.Handle, BM_CLICK, 0, 0);
end
end;

procedure InstallButtonClick(Sender: TObject);
var
CurPageID: Integer;
begin
Exec(ExpandConstant('{src}\Setup.exe'),'','',SW_SHOW,ewNoWait,ResultCode)
AutoRun.Close;
PostMessage(WizardForm.CancelButton.Handle, BM_CLICK, 0, 0);
end;

procedure SupportButtonClick(Sender: TObject);
begin
shellexec('open', ExpandConstant('{src}\Game.exe'), '', '',SW_SHOWNORMAL, ewnowait, ResultCode)
end;

procedure ReadmeButtonClick(Sender: TObject);
begin
ShellExec('open', ExpandConstant('{src}\readme.txt'),'','', SW_SHOW, ewNoWait, ResultCode)
end;

procedure WebButtonClick(Sender: TObject);
begin
shellexec('open', 'http://localhost', '', '',SW_SHOWNORMAL, ewnowait, ResultCode)
end;

procedure ExitButtonClick(Sender: TObject);
var
CurPageID: Integer;
begin
AutoRun.Close;
PostMessage(WizardForm.CancelButton.Handle, BM_CLICK, 0, 0);
end;

procedure UninstallButtonClick(Sender: TObject);
begin
if RegQueryStringValue(HKLM, 'SOFTWARE\Game','UninstallString', UninsPath) then
begin
UninsPath:=RemoveQuotes(UninsPath)
Exec(UninsPath,'','',SW_SHOWNORMAL,ewNoWait,ResultCode)
AutoRun.Close;
PostMessage(WizardForm.CancelButton.Handle, BM_CLICK, 0, 0);
end
end;

procedure CreateAutoRun;
begin
//AutoRun
AutoRun := CreateCustomForm;
with AutoRun do begin
Left := 498;
Top := 75;
Width := 495;
Height := 340;
BorderIcons := [];
BorderStyle:=bsToolWindow //(bsNone, bsSingle, bsSizeable, bsDialog, bsToolWindow, bsSizeToolWin)
Color := clBtnFace;
Font.Color := clWindowText;
Font.Height := -11;
Font.Name := 'MS Sans Serif';
Font.Style := [];
Position := poScreenCenter;
Caption:='AutoRUN'
end;
//img1
img1 := TBitmapImage.Create(AutoRun);
ExtractTemporaryFile('1.bmp');
with img1 do begin
Parent := AutoRun;
Left := 0;
Stretch:= true;
Top := 0;
Width := Autorun.Width;
Height := Autorun.Height;
Bitmap.LoadFromFile(ExpandConstant('{tmp}\1.bmp'));
end;
//PlayButton
PlayButton:= TButton.Create(AutoRun);
with PlayButton do begin
Parent := AutoRun;
Left := 300;
Top := 110;
Width := 150;
Height := 22;
Caption:= 'Начать игру';
Cursor:= crHand;
// ModalResult:= mrOk;
OnClick := @PlayButtonClick;
if not RegQueryStringValue(HKLM, 'SOFTWARE\Game','Install Dir', AppPath) then
begin
PlayButton.Enabled := False;
end
end;
//InstallButton
InstallButton:= TButton.Create(AutoRun);
with InstallButton do begin
Parent:= AutoRun;
Left := 300;
Top := 80;
Width := 150;
Height := 22;
Caption:= 'Install Game';
Cursor:= crHand;
OnClick := @InstallButtonClick;
end;
//SupportButton
SupportButton:= TButton.Create(AutoRun);
with SupportButton do begin
Parent:= AutoRun;
Left := 300;
Top := 140;
Width := 150;
Height := 22;
Caption:= 'Инфо';
Cursor:= crHand;
OnClick := @SupportButtonClick;
end;
//ReadmeButton
ReadmeButton:= TButton.Create(AutoRun);
with ReadmeButton do begin
Parent:= AutoRun;
Left := 300;
Top := 170;
Width := 150;
Height := 22;
Caption:= 'Readme';
Cursor:= crHand;
OnClick := @ReadmeButtonClick;
end;
//WebButton
WebButton:= TButton.Create(AutoRun);
with WebButton do begin
Parent:= AutoRun;
Left := 300;
Top := 200;
Width := 150;
Height := 22;
Caption:= 'Веб-сайт';
Cursor:= crHand;
OnClick := @WebButtonClick;
end;
//ExitButton
ExitButton:= TButton.Create(AutoRun);
with ExitButton do begin
Parent:= AutoRun;
Left := 300;
Top := 260;
Width := 150;
Height := 22;
Caption:= 'Выход';
Cursor:= crHand;
OnClick := @ExitButtonClick;
// ModalResult:= mrCancel;
end;
//UninstallButton
UninstallButton:= TButton.Create(AutoRun);
with UninstallButton do begin
Parent:= AutoRun;
Left := 300;
Top := 230;
Width := 150;
Height := 22;
Caption:= 'Удалить игру';
Cursor:= crHand;
OnClick := @UninstallButtonClick;
end;

if not RegQueryStringValue(HKLM, 'SOFTWARE\Game','UninstallString', UninsPath) then
begin
InstallButton.Enabled:=true;
UninstallButton.Enabled:=false;
end;
if RegQueryStringValue(HKLM, 'SOFTWARE\Game','UninstallString', UninsPath) then
begin
InstallButton.Enabled:=false;
UninstallButton.Enabled:=true;
end;

AutoRun.ShowModal;
end;

procedure InitializeWizard;
begin
CreateAutoRun;
end;
[/more]
Он полностью рабочий.
Если такой умный, разберешься без чужой помощи...
И сам все сделаешь
Автор: TonyJef
Дата сообщения: 06.08.2010 15:07
откуда такая уверенность?


Добавлено:
JohnDes,cпасибо,но разве это для антологии?
Автор: dumanow1
Дата сообщения: 06.08.2010 15:27
Profrager ответьте в личке пожалуйста
Автор: TonyJef
Дата сообщения: 06.08.2010 15:29
JohnDes,ну разобрался в нем и что дальше?
Автор: ChanVS
Дата сообщения: 06.08.2010 15:56
Кто подскажет, где не так в скрипте написано.
Из всех файлов подсчет идет только *.PCF и *.exe, а *.ogg нет.
И еще как создать пробел между:
"файлов 3, 75,3%, выполнено, осталось ждать 1 мин 20 сек"
Буду благодарен!
Автор: StalkMent
Дата сообщения: 06.08.2010 16:18
ChanVS
Какой у тебя скрипт?
Автор: ChanVS
Дата сообщения: 06.08.2010 16:37
Вообщем я переделал Call of Duty WW FreeArc+ Isprecomp.
Просто рапаковывается файлы и преобразуются Precomp свои и oggdec свои.
С прогресбаром pcf и ogg.
Если б помогли убрать не нужные строчьки и добавить Status.
StatusLabel добавил.

Добавлено:
StalkMent

Убрать чтоб я не путался.
А так пусть будет в резерве!
Автор: StalkMent
Дата сообщения: 06.08.2010 16:46
ChanVS
Я мысли не читаю и скрипт с твоего компа считать не могу а ток мог бы помочь по одному пункту.
Автор: ChanVS
Дата сообщения: 06.08.2010 16:52
[more]
#define MyAppName "Call of Duty - Modern Warfare"
#define NeedSize "6315"
#define PB_ImageFile "progress1.bmp"
#ifdef UNICODE
#define PStr "AnsiString"
#else
#define PStr "String"
#endif

[Setup]
AppName=Call of Duty - Modern Warfare
AppVerName=Call of Duty - Modern Warfare
DefaultDirName={pf}\Call of Duty - Modern Warfare
DirExistsWarning=no
ShowLanguageDialog=auto
Compression=none
OutputBaseFilename=Setup
OutputDir=D:\repack
SolidCompression=true
DiskSpanning=yes
SlicesPerDisk=5
DiskSliceSize=1100000000
DisableProgramGroupPage=true
DisableReadyPage=True
DefaultGroupName=Activision\Call of Duty - Modern Warfare

[_ISToolPreCompile]
#sub ShowErr
#pragma error Str(void)
#endsub
#define Break(any S = "Empty") void = S, ShowErr
#ifndef Archives
#define Archives ""
#endif
#define LastLine
#define Current AddBackslash(GetEnv("TEMP")) + GetDateTimeString('dd/mm-hh:nn', '-', '-') +'.iss'
#sub GetLastLine
#expr SaveToFile(Current)
#for {faAnyFile = FileOpen(Current); !FileEof(faAnyFile); LastLine = FileRead(faAnyFile)} NULL
#expr FileClose(faAnyFile)
#endsub
#define TrimEx(str S = "", str T = " ") \
Pos(T,S) == 1 ? S = Copy(S,2,Len(S)) : S, Copy(S,Len(S)) == T ? S = Copy(S,1,Len(S)-1) : S, Pos(T,S) == 1 || Copy(S,Len(S)) == T ? TrimEx(S,T) : S
#define SkipText(str S = "", str T = ";", int F = 1) \
Local[0] = Pos(T, S), Local[0] > 0 ? (F == 0 ? Copy(S, Local[0]) : (F < 0 ? Copy(S,,Local[0] -1) : Copy(S, Local[0] + Len(T)))) : S
#define Find2Cut(str S, str B, str E = ";") \
S = LowerCase(S), B = LowerCase(B), \
(Local[0] = Pos(B, S)) > 0 ? (Local[1] = Copy(S, Local[0]+Len(B)), (Local[0] = Pos(E, Local[1])) > 0 ? (Copy(Local[1],, Local[0]-1)) : Local[1]) : ""
#define SourceToProgress() GetLastLine, \
Local[0] = Find2Cut(LastLine,"UnArc(",")"), Local[0] == "" ? Local[0] = Find2Cut(LastLine,"UnZip(",")") : void, Local[0] != "" && Pos("dontcopy", Find2Cut(LastLine,"Flags:")) == 0 ? Local[5] = "?" : void, \
Local[1] = TrimEx(TrimEx(SkipText(Local[0],"',",-1)),"'"), Local[2] = TrimEx(TrimEx(SkipText(Local[0],"',")),"'"), Local[1] == "" ? Local[1] = TrimEx(Find2Cut(LastLine,"Source:")) : void, Local[2] == "" ? Local[2] = TrimEx(Find2Cut(LastLine,"DestDir:")) : void, \
Local[3] = TrimEx(Find2Cut(LastLine,"Components:")), Local[3] == "" ? void : (Local[3] = "<"+ Local[3], void), Local[4] = TrimEx(Find2Cut(LastLine,"Tasks:")), Local[4] == "" ? void : (Local[4] = ">"+ Local[4], void), \
Local[1] == "" ? Break('Previous line must be in [Files] section') : (Local[0] = Local[1] +"/"+ Local[2] + Local[3] + Local[4] + Local[5]), TrimEx(Archives) == "" ? Archives = Local[0] : (Archives = Archives +"|"+ Local[0]), void
#define isFalse(any S) (S = LowerCase(Str(S))) == "no" || S == "false" || S == "off" ? "true" : "false"

[UninstallDelete]
Type: filesandordirs; Name: {app}

[CustomMessages]
russian.Welcome1=Вас приветствует Мастер установки игры
russian.Welcome2=Программа установит игру {#MyAppName} на Ваш компьютер.%n%nРекомендуется закрыть антивирусные пакеты, а также все прочие приложения перед тем, как продолжить.%n%nНажмите «Далее», чтобы продолжить, или «Отмена», чтобы выйти из программы установки.
russian.Space=Доступно места на диске:
russian.Space1=Требуется места на диске:
russian.Status=Пожалуйста, подождите, пока игра установится на Ваш компьютер.
russian.DescrLbl1=В какую папку Вы хотите установить {#MyAppName}?
russian.Language=Выберите язык игры
russian.StartMenuLbl=Нажмите «Установить», чтобы продолжить. Если Вы хотите выбрать другую папку, нажмите «Обзор».
russian.Finished1=Установка игры {#MyAppName} успешно завершена.
russian.Finished2=Игра {#MyAppName} была успешно установлена на Ваш компьютер. Для ее запуска выберите соответствующий ярлык в меню «Пуск» или ярлык на Рабочем столе.
russian.Finished3=Нажмите «Завершить», чтобы выйти из программы установки.
russian.DirectX=Обновить DirectX
russian.DirectXInstall=Идет обновление DirectX...
russian.Icons=Добавить ярлык на Рабочий стол
russian.Uninstall=Удалить {#MyAppName}
russian.ArcBreak=Установка прервана!
russian.ArcError=Распаковщик FreeArc вернул код ошибки: %1
russian.ArcBroken=Возможно, архив <%1> повреждён или недостаточно места на диске назначения.
;russian.PassFail=Неверный пароль!
russian.ArcFail=Распаковка не завершена!
russian.ArcTitle=Распаковка FreeArc-архивов...
;russian.Szip=Распаковка 7zip-архивов...
russian.StatusInfo=файлов: %1%2, %3%% выполнено, осталось ждать %4
russian.ArcInfo=Архив %1 из %2, объём %3 из %5, %4%% обработано
russian.ArcFinish=Распаковано архивов: %1, получено файлов: %2 [%3]
russian.taskbar=%1%%, жди %2
russian.ending=завершение
russian.hour= часов
russian.min= мин
russian.sec= сек

[Languages]
Name: "russian"; MessagesFile: "compiler:Languages\Russian.isl"

[Icons]
Name: {group}\Запустить игру; Filename: {app}\iw3sp.exe; WorkingDir: {app}
Name: {group}\Запустить сетевую игру; Filename: {app}\iw3mp.exe; WorkingDir: {app}
Name: {group}\Удаление игры; Filename: {uninstallexe}; WorkingDir: {app}

[Files]
;эти файлы необходимы для работы isprecomp
Source: isprecomp\unarc.dll; DestDir: {tmp}; Flags: dontcopy
Source: isprecomp\InnoCallback.dll; DestDir: {tmp}; Flags: dontcopy
Source: isprecomp\isprecomp.dll; DestDir: {tmp}; Flags: dontcopy
Source: precomp\*; DestDir: {tmp}; Flags: nocompression
;Оформление
Source: Pic\1.bmp; Flags: dontcopy;
Source: Pic\2.bmp; Flags: dontcopy;
Source: Pic\3.bmp; Flags: dontcopy;
Source: Pic\4.bmp; Flags: dontcopy;
Source: Pic\5.bmp; Flags: dontcopy;
Source: {app}\ISSkin.dll; DestDir: {app}; Flags: ignoreversion;
Source: Pic\button.bmp; Flags: dontcopy;
;строки распаковки архивов
Source: {038}\*.pcf; DestDir: {app}\zone\; Flags: deleteafterinstall;
Source: oggdec.exe; DestDir: {app}; Flags: deleteafterinstall;
Source: gren\*; DestDir: {app}\gren; Flags: deleteafterinstall;
{#SourceToProgress}


[Code]
type
TProc = procedure(HandleW, msg, idEvent, TimeSys: LongWord);
#ifdef UNICODE
#define A "W"
#else
#define A "A" ;// точка входа в SetWindowText, {#A} меняется на A или W в зависимости от версии
// PAnsiChar = PChar; // Required for Inno Setup 5.3.0 and lower. (требуется для Inno Setup версии 5.3.0 и ниже)
#endif
#if Ver < 84018176
AnsiString = String; // There is no need for this line in Inno Setup 5.2.4 and above (для Inno Setup версий 5.2.4 и выше эта строка не нужна)
#endif

TMessage = record hWnd: HWND; msg, wParam: Word; lParam: LongWord; Time: TFileTime; pt: TPoint; end;
TFreeArcCallback = function (what: PAnsiChar; int1, int2: Integer; str: PAnsiChar): Integer;
TPrecompCallback = procedure(progress: integer); //isprecomp
TArc = record Path, Dest, comp, task: string; allMb, Files: Integer; Size: Extended; end;
TBarInfo = record stage, name: string; size, allsize: Extended; count, perc, pos, mb, time: Integer; end;
TCWPSTRUCT = record lParam: LongWord; wParam: Word; Msg: LongWord; hwnd: HWnd; end;
TCWPSTRUCTProc = procedure(Code: Integer; wParam: Word; lParam: TCWPSTRUCT);
TTimerProc = procedure(HandleW, Msg, idEvent, TimeSys: LongWord);
var

Files: Array of String;
S: String;
n: Integer;
m: Integer;

ButtonPanel: array [0..4] of TPanel;
ButtonImage: array [0..4] of TBitmapImage;
ButtonLabel: array [0..4] of TLabel;

WndHookID, TimerID: LongWord;
intOldCurrWidth : Integer;
ProgressBar_BitmapImage: TBitmapImage;
ProgressBar_Edit : TEdit;
ProgressBar_ImageHeight : integer;

LanguageLabel1: TLabel;
LanguageLabel2: TLabel;

rus: Boolean;
pnl_ru, pnl_us: TPanel;

mp3Handle: HWND;
mp3Name: String;

PlayButton, PauseButton, StopButton: TPanel;
PlayImage, PauseImage: TBitmapImage;
PlayLabel, PauseLabel: TLabel;
MouseLabel: Tlabel;

Welcome, Parameters, StartMenu, Installing, Finish,
IconsLabel, NoIconsLabel, DirectXLabel, GroupLabel,
SelectDirLabel, SelectDirBrowseLabel,
PageNameLabel1, PageNameLabel2, PageNameLabel3,
PageDescriptionLabel1, PageDescriptionLabel2, PageDescriptionLabel3,
NeedSpaceLabel,FreeSpaceLabel,
WelcomeLabel1, WelcomeLabel2,FinishedLabel, FinishedHeadingLabel,
SelectStartMenuFolderLabel, SelectStartMenuFolderBrowseLabel, ReadyLabel: TLabel;
DirectX, Icons, NoIconsCheck, Group: TCheckBox;
NeedSize:Integer;
FreeMB, TotalMB: Cardinal;
BmpFile: TBitmapImage;
StatusLabel, FileNameLabel, ExtractFile, StatusInfo: TLabel;
ProgressBar: TNewProgressBar;
ProgressBar2: TNewProgressBar;
CancelCode, ArcInd, UnPackError, StartInstall, LastTimerEvent, lastMb, baseMb: Integer;

Arcs, Records: array of TArc;
msgError: string;
Status: TBarInfo;
FreezeTimer: Boolean;
totalUncompressedSize, origsize: Integer; // total uncompressed size of archive data in mb
Texture2, Texture: TBitmapImage;
PrecompFiles: Integer;
PrecompLabel: TLabel;
DestDir: String;
ProgressLabel: TLabel;
btnCancelRecompress: TButton;


const
ButtonWidth = 80;
ButtonHeight = 23;

bidBack = 0;
bidNext = 1;
bidCancel = 2;
bidDirBrowse = 3;
bidGroupBrowse = 4;

BASS_ACTIVE_PLAYING = 1;
BASS_ACTIVE_STALLED = 2;
BASS_ACTIVE_PAUSED = 3;
BASS_SAMPLE_LOOP = 4;

PM_REMOVE = 1;
CP_ACP = 0; CP_UTF8 = 65001;
oneMB=1024*1024;
Period = 250; // частота обновления кнопки таскбара и строки статуса
BackColor = $fcfbfb; EndColor = $d8e9ec; // цвета подобраны для темы Луна
VK_ESCAPE = 27;
HC_ACTION = 0;
WH_CALLWNDPROC = 4;
WM_PAINT = $F;
CancelDuringInstall = {#isFalse(SetupSetting("AllowCancelDuringInstall"))};

// Функции для работы с таймером
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 WrapFreeArcCallback (callback: TFreeArcCallback; paramcount: integer):longword; external 'wrapcallback@files:innocallback.dll stdcall';
function WrapPrecompCallback(callback:TPrecompCallback; paramcount:integer):longword; external 'wrapcallback@files:innocallback.dll stdcall';
procedure PrecompBreak; external 'precomp_break@files:isprecomp.dll stdcall delayload';

Function OemToChar(lpszSrc, lpszDst: AnsiString): longint; external 'OemToCharA@user32.dll stdcall';
Function MultiByteToWideChar(CodePage: UINT; dwFlags: DWORD; lpMultiByteStr: PAnsiChar; cbMultiByte: integer; lpWideCharStr: PAnsiChar; cchWideChar: integer): longint; external 'MultiByteToWideChar@kernel32.dll stdcall';
Function WideCharToMultiByte(CodePage: UINT; dwFlags: DWORD; lpWideCharStr: PAnsiChar; cchWideChar: integer; lpMultiByteStr: PAnsiChar; cbMultiByte: integer; lpDefaultChar: integer; lpUsedDefaultChar: integer): longint; external 'WideCharToMultiByte@kernel32.dll stdcall';

function PeekMessage(var lpMsg: TMessage; hWnd: HWND; wMsgFilterMin, wMsgFilterMax, wRemoveMsg: UINT): BOOL; external 'PeekMessageA@user32.dll stdcall';
function TranslateMessage(const lpMsg: TMessage): BOOL; external 'TranslateMessage@user32.dll stdcall';
function DispatchMessage(const lpMsg: TMessage): Longint; external 'DispatchMessageA@user32.dll stdcall';

function GetTickCount: DWord; external 'GetTickCount@kernel32';
function GetWindowLong(hWnd, nIndex: Integer): Longint; external 'GetWindowLongA@user32 stdcall delayload';
function SetWindowText(hWnd: Longint; lpString: String): Longint; external 'SetWindowText{#A}@user32 stdcall delayload';
function GetKeyState(nVirtKey: Integer): ShortInt; external 'GetKeyState@user32 stdcall delayload';
function GetCurrentThreadID: LongWord; external 'GetCurrentThreadId@kernel32 stdcall delayload';
function MulDiv(Number, Numerator, Denominator: Integer): Integer; external 'MulDiv@kernel32 stdcall delayload';

function CallNextWNDPROC(idHook: LongWord; Code: Integer; wParam: Word; lParam: TCWPSTRUCT): LongWord; external 'CallNextHookEx@user32 stdcall delayload';
function SetWindowsHookEx(idHook: LongWord; callback: LongWord; hMod: LongWord; dwThreadID: HWND): LongWord; external 'SetWindowsHookExW@user32 stdcall delayload';
function UnhookWindowsHookEx(idHook: LongWord): LongWord; external 'UnhookWindowsHookEx@user32 stdcall delayload';
function WrapCWPSTRUCTProc(callback:TCWPSTRUCTProc; paramcount:integer): longword; external 'wrapcallback@files:innocallback.dll';



function DetectPage(CurPageID: Integer): TNewNotebookPage;
begin
case CurPageID of
wpWelcome: Result:= WizardForm.WelcomePage;
wpSelectDir: Result:= WizardForm.SelectDirPage;
wpSelectProgramGroup: Result:= WizardForm.SelectProgramGroupPage;
wpSelectTasks: Result:= WizardForm.SelectTasksPage;
wpInstalling: Result:= WizardForm.InstallingPage;
wpFinished: Result:= WizardForm.FinishedPage;
end;
end;

function InstallDirectX: Boolean;
begin
Result:= DirectX.Checked;
end;

function CreateIcons: Boolean;
begin
Result:=Icons.Checked;
end;

function GroupIcons: Boolean;
begin
Result:=Group.Checked;
end;

function BackButtonClick(CurPageID: Integer): Boolean;
begin
Result := True;
if CurPageID = wpSelectDir then
ButtonPanel[bidNext].Enabled := True;
end;

procedure DirectXLabelOnClick(Sender: TObject);
begin
if DirectX.Checked = False then
DirectX.Checked:= True else
DirectX.Checked:= False;
end;

procedure IconsOnClick(Sender: TObject);
begin
if Icons.Checked = False then
Icons.Checked:= True else
Icons.Checked:= False;
end;

procedure CheckStartMenuOnClick(Sender: TObject);
begin
if WizardForm.NoIconsCheck.Checked then
begin
WizardForm.GroupEdit.Enabled := not (WizardForm.GroupEdit.Enabled);
WizardForm.GroupBrowseButton.Enabled := False;
ButtonLabel[bidGroupBrowse].Enabled := False;
ButtonPanel[bidGroupBrowse].Enabled := False;
end else
begin
WizardForm.GroupEdit.Enabled := True;
WizardForm.GroupEdit.Enabled := WizardForm.GroupEdit.Enabled;
WizardForm.GroupBrowseButton.Enabled := True;
ButtonLabel[bidGroupBrowse].Enabled := True;
ButtonPanel[bidGroupBrowse].Enabled := True;
end;
end;

procedure CheckNoIconsCheck(Sender: TObject);
begin
if (WizardForm.NoIconsCheck.Checked = False) then
WizardForm.NoIconsCheck.Checked := True
else
WizardForm.NoIconsCheck.Checked := False;
end;

procedure CurStepChanged1(CurStep: TSetupStep);
begin
if CurStep = ssPostInstall then
if Icons.Checked then
CreateShellLink(ExpandConstant('{group}\Call of Duty - Modern Warfare.lnk'), '',
ExpandConstant('{app}\nfs.exe'), '', ExpandConstant('{app}'), '', 0, SW_SHOWNORMAL);
end;

// Перевод числа в строку с точностью 2 знака (%.2n) с округлением дробной части, если она есть
Function NumToStr(Float: Extended): String;
Begin
Result:= Format('%.2n', [Float]); StringChange(Result, ',', '.');
while ((Result[Length(Result)] = '0') or (Result[Length(Result)] = '.')) and (Pos('.', Result) > 0) do
SetLength(Result, Length(Result)-1);
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 := ExpandConstant('{cm:SPACE} ')+ NumToStr(round(FreeMB/1024*100)/100) + ' GB' else
FreeSpaceLabel.Caption := ExpandConstant('{cm:SPACE} ')+ NumToStr(FreeMB)+ ' MB';
end;

procedure GetNeedSpaceCaption;
begin
if NeedSize > 1024 then
NeedSpaceLabel.Caption := ExpandConstant('{cm:SPACE1} ')+ NumToStr(round(NeedSize/1024*100)/100) + ' GB' else
NeedSpaceLabel.Caption := ExpandConstant('{cm:SPACE1} ')+ NumToStr(NeedSize)+ ' MB';
end;

procedure ProgressExt();
begin
FilenameLabel.Caption:= ExpandConstant(ExtractFileDir(CurrentFilename)) + '\' + ExtractFilename(CurrentFilename);
end;

procedure ProgressExt2();
begin
FilenameLabel.Caption:= ExpandConstant('{cm:DirectXInstall}')
end;


procedure AppProcessMessage;
var
Msg: TMessage;
begin
if not PeekMessage(Msg, {WizardForm.Handle} 0, 0, 0, PM_REMOVE) then Exit;
TranslateMessage(Msg); DispatchMessage(Msg);
end;


// Sets the TaskBar title
Procedure SetTaskBarTitle(Title: String); var h: Integer;
Begin
h:= GetWindowLong(MainForm.Handle, -8); if h <> 0 then SetWindowText(h, Title);
End;

Function cm(Message: String): String; Begin Result:= ExpandConstant('{cm:'+ Message +'}') End;
Function LoWord(lw: LongWord): LongWord; Begin Result:= lw shr 16; End;

Function ByteOrTB(Bytes: Extended; noMB: Boolean): String; {Перевод числа в значение бт/Кб/Мб/Гб/Тб (до 2х знаков после запятой)}
Begin
if not noMB then Result:= NumToStr(Int(Bytes)) +' Mb' else
if Bytes < 1024 then if Bytes = 0 then Result:= '0' else Result:= NumToStr(Int(Bytes)) +' Bt' else
if Bytes/1024 < 1024 then Result:= NumToStr(round((Bytes/1024)*10)/10) +' Kb' else
If Bytes/oneMB < 1024 then Result:= NumToStr(round(Bytes/oneMB*100)/100) +' Mb' else
If Bytes/oneMB/1000 < 1024 then Result:= NumToStr(round(Bytes/oneMB/1024*1000)/1000) +' Gb' else
Result:= NumToStr(round(Bytes/oneMB/oneMB*1000)/1000) +' Tb';
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;

Function CreateLabel(Parent: TWinControl; AutoSize, WordWrap, Transparent: Boolean; FontName: String; FontStyle: TFontStyles; FontColor: TColor; Left, Top, Width, Height: Integer; Prefs: TObject): TLabel;
Begin
Result:=TLabel.Create(Parent); Result.parent:= Parent;
if Prefs <> Nil then begin
Top:= TWinControl(Prefs).Top; Left:= TWinControl(Prefs).Left; Width:= TWinControl(Prefs).Width; Height:= TWinControl(Prefs).Height;
end;
if Top > 0 then result.Top:=Top; if Left > 0 then result.Left:= Left; if Width > 0 then result.Width:= Width; if Height > 0 then result.Height:= Height;
if FontName <> '' then result.Font.Name:= FontName; if FontColor > 0 then result.Font.Color:= FontColor; if FontStyle <> [] then result.Font.Style:= FontStyle;
result.AutoSize:= AutoSize; result.WordWrap:= WordWrap; result.Transparent:=Transparent; result.ShowHint:= true;
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 RecodePCF;
var
ResultCode: integer; CurFile: String;
ProgressBar: TNewProgressBar;
ProgressBar2: TNewProgressBar;
begin
ExtractTemporaryFile('precomp.exe'); ExtractTemporaryFile('packjpg_dll.dll')
FindFiles(ExpandConstant('{app}'), '*.pcf')
Files:= StringToArray(S, '|')
WizardForm.ProgressGauge.Max:= GetArrayLength(Files);
StatusLabel.Caption:= 'Преобразование файлов. Пожалуйста подождите';
Status.stage:= StatusLabel.Caption; ExtractFile.Hide;
ProgressBar := TNewProgressBar.Create(WizardForm);
ProgressBar2:= TNewProgressBar.Create(WizardForm);
with ProgressBar do begin
Left := WizardForm.ProgressGauge.Left;
Top := WizardForm.ProgressGauge.Top + ScaleX(60);
Width := WizardForm.ProgressGauge.Width/2;
Height := WizardForm.ProgressGauge.Height;
Parent := WizardForm.InstallingPage;
Min := 0;
Max := GetArrayLength(Files);
Position := 0;
show;
with ProgressBar2 do begin
Left := WizardForm.ProgressGauge.Left + ScaleY(310);
Top := WizardForm.ProgressGauge.Top + ScaleX(60);
Width := 280;
Height := WizardForm.ProgressGauge.Height;
Parent := WizardForm.InstallingPage;
Min := 0;
Max := 100;
Position := 0;
show;
end;
for n:=(GetArrayLength(Files)-1) downto 0 do begin
FileCopy(ExpandConstant('{tmp}\precomp.exe'),AddBackslash(ExtractFilePath(Files[n]))+'precomp.exe', False)
FileCopy(ExpandConstant('{tmp}\packjpg_dll.dll'),AddBackslash(ExtractFilePath(Files[n]))+'packjpg_dll.dll', False)
WizardForm.FilenameLabel.Caption:= Files[n];
Exec(AddBackslash(ExtractFilePath(Files[n]))+'precomp.exe', '-d '+AddQuotes(Files[n]), '', SW_Hide, EwWaitUntilTerminated, ResultCode)
ProgressBar.Position:= ProgressBar.Position +1;
DeleteFile(Files[n])
DeleteFile(AddBackslash(ExtractFilePath(Files[n]))+'packjpg_dll.dll')
DeleteFile(AddBackslash(ExtractFilePath(Files[n]))+'precomp.exe')
end;
end;
end;

procedure RecodeOgg;
var
ResultCode: integer; CurFile: String;
ProgressBar2: TNewProgressBar;
begin
FindFiles(ExpandConstant('{app}\gren'), '*.ogg') //Находим все файлы по маске, в выбранной папке
Files:= StringToArray(S, '|') //Переводим в массив
StatusLabel.Caption:='Преобразование звуковых файлов...';
Status.stage:= StatusLabel.Caption; ExtractFile.Hide;
ProgressBar2 := TNewProgressBar.Create(WizardForm);
with ProgressBar2 do begin
Left := 410;
Top := WizardForm.ProgressGauge.Top + ScaleX(60);
Width := 280;
Height := WizardForm.ProgressGauge.Height;
Parent := WizardForm.InstallingPage;
Min := 0;
Max := 10;
Position := 0;
show;
for m:=(GetArrayLength(Files)-1) downto 0 do begin
CurFile:= Files[m]
StringChange(CurFile, AddBackslash(ExpandConstant('{app}')), '')
Exec(ExpandConstant('{app}\oggdec.exe'), '-Q '+AddQuotes(CurFile), '', SW_Hide, EwWaitUntilTerminated, ResultCode) //Для каждого файла запускаем декодер
DeleteFile(Files[m]) //Удаляем ненужный файл
WizardForm.FilenameLabel.Caption:= Files[m]; //Двигаем прогрессбар
ProgressBar2.Position:= ProgressBar2.Position +1;
end;
DeleteFile(ExpandConstant('{app}\oggdec.exe'))
end;
end;

// Converts milliseconds to human-readable time
// Конвертирует милисекунды в человеко-читаемое изображение времени
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;

Function ExpandENV(string: String): String; var n: UINT; Begin // ExpandConstant + развёртывание DOS-переменных типа %SystemRoot%
if Pos('{',string) * Pos('}',string) = 0 then Result:= String else Result:= ExpandConstant(String); n:= Pos('%',result); if n = 0 then Exit;
Delete(result, n,1); Result:= Copy(Result,1, n-1) + ExpandConstant('{%'+Copy(Result, n, Pos('%',result) -n) +'}') + Copy(Result, Pos('%',result) +1, Length(result))
End;

Function Size64(Hi, Lo: Integer): Extended;
Begin
Result:= Lo;
if Lo<0 then Result:= Result + $7FFFFFFF + $7FFFFFFF + 2;
for Hi:= Hi-1 Downto 0 do
Result:= Result + $7FFFFFFF + $7FFFFFFF + 2;
End;

Function RGB(r, g, b: Longint): Longint; Begin Result:= (r or (g shl 8) or (b shl 16)) End;
Function GetBValue(rgb: DWord): Byte; Begin Result:= Byte(rgb shr 16) End;
Function GetGValue(rgb: DWord): Byte; Begin Result:= Byte(rgb shr 8) End;
Function GetRValue(rgb: DWord): Byte; Begin Result:= Byte(rgb) End;

Procedure GradientFill(WorkBmp: TBitmapImage; BeginColor, FinishColor: Integer); var ColorBand: TRect; StartColor, i: Integer; Begin {если BeginColor < 0, то градиент горизонтальный}
WorkBmp.Bitmap.Width:= WorkBmp.Width; WorkBmp.Bitmap.Height:= WorkBmp.Height; StartColor:= trunc(Abs(BeginColor))
if BeginColor < 0 then n:= WorkBmp.Width else n:= WorkBmp.Height;
for i:=0 to n do begin if BeginColor < 0 then begin
ColorBand.Top:= 0; ColorBand.Bottom:= WorkBmp.Height;
ColorBand.Left:= MulDiv(i, WorkBmp.Width, n); ColorBand.Right:= MulDiv(i+1, WorkBmp.Width, n);
end else begin
ColorBand.Top:= MulDiv(i, WorkBmp.Height, n); ColorBand.Bottom:= MulDiv(i+1, WorkBmp.Height, n);
ColorBand.Left:= 0; ColorBand.Right:= WorkBmp.Width; end;
WorkBmp.Bitmap.Canvas.Brush.Color:= RGB(GetRValue(StartColor) + MulDiv(I, GetRValue(FinishColor) - GetRValue(StartColor), n-1), GetGValue(StartColor) + MulDiv(I, GetGValue(FinishColor) - GetGValue(StartColor), n-1), GetBValue(StartColor) + MulDiv(I, GetBValue(FinishColor) - GetBValue(StartColor), n-1));
WorkBmp.Bitmap.Canvas.FillRect(ColorBand); end;
End;

// Converts OEM encoded string into ANSI (Преобразует OEM строку в ANSI кодировку)
function OemToAnsiStr(strSource: AnsiString): AnsiString;
var
nRet : longint;
begin
SetLength(Result, Length(strSource));
nRet:= OemToChar(strSource, Result);
end;

// Converts ANSI encoded string into UTF-8 (Преобразует строку из ANSI в UTF-8 кодировку)
function AnsiToUtf8(strSource: string): string;
var
nRet, nRet2: integer; WideCharBuf, MultiByteBuf: AnsiString;
begin
SetLength(WideCharBuf, Length(strSource) * 2);
SetLength(MultiByteBuf, Length(strSource) * 2);
nRet:= MultiByteToWideChar(CP_ACP, 0, strSource, -1, WideCharBuf, Length(WideCharBuf));
nRet2:= WideCharToMultiByte(CP_UTF8, 0, WideCharBuf, -1, MultiByteBuf, Length(MultiByteBuf), 0, 0);
if nRet * nRet2 = 0 then Result:= strSource else Result:= MultiByteBuf;
end;

// ArcInd - текущий архив, счёт с 0
// baseMb - записано из пред. архива на диск
// lastMb - извлечено из тек. архива на диск
// Status.mb - позиция в текущем архиве
// Status.allsize - объём всех архивов
// Status.size - всего извлечено Мб на текущий момент
// totalUncompressedSize - точный объём данных в архивах
// общий прогресс нарастает по мере записи данных из архива на диск (точка 'write')
// прогресс архивов двигается в соответствии с позицией в текущем архиве (точка 'read')

Procedure UpdateStatus(Flags: Integer); // выполняется с периодичностью, заданной константой Period
var
Remaining: Integer; i, t, s: string;
Begin
if Flags and $1 > 0 then FreezeTimer:= Flags and $2 = 0; // bit 0 = 1 change start/stop, bit 1 = 0 stop, bit 1 = 1 start
if (Flags and $4 > 0) or (Status.size <> baseMb+lastMb) then LastTimerEvent:= 0; // bit 2 = 1 UpdateNow // обновить по флагу или записи из архива на диск
if FreezeTimer or (GetTickCount - LastTimerEvent <= Period) then Exit else LastTimerEvent:= GetTickCount;
Status.size := baseMb+lastMb; // извлечено на текущий момент
if totalUncompressedSize > 0 then with WizardForm.ProgressGauge do begin // основной прогресс движется по мере записи данных на диск
Position:= round(Max * Status.size/totalUncompressedSize)
end;
with WizardForm.ProgressGauge do begin // оставшееся время
#ifndef precomp
// к сожалению, этот код иногда сбоит на очень больших архивах, созданных с использованием внешних упаковщиков
if position > 0 then Remaining:= trunc((GetTickCount - StartInstall) * Abs((max - position)/position)) else
#endif
Remaining:= 0;
t:= cm('ending'); i:= t;
if Remaining > 0 then begin
t:= FmtMessage(cm('taskbar'), [IntToStr(Status.perc/10), TicksToTime(Remaining, 'h', 'm', 's', false)])
i:= TicksToTime(Remaining, cm('hour'), cm('min'), cm('sec'), false)
end;
end;
SetTaskBarTitle(t); // проценты и оставшееся время на кнопке инсталлятора
if Status.size > 0 then
s:= ' ['+ ByteOrTB(Status.size*oneMB, true) +']'; // если сделать подсчёт размера папки {app} через CalcDirSize, то при частом пересчёте папки большого объёма это может замедлить работу
StatusInfo.Caption:= FmtMessage(cm('StatusInfo'), [IntToStr(Status.count +ord(Status.count < 0)), s, Format('%.1n', [Abs(Status.perc/10)]), i]);
// второй прогрессбар движется по мере считывания текущего архива
if (Status.stage = cm('ArcTitle')) and (GetArrayLength(Arcs) > 0) then begin
ExtractFile.Caption:= FmtMessage(cm('ArcInfo'), [IntToStr(ArcInd+1), IntToStr(GetArrayLength(Arcs)), ByteOrTB(Arcs[ArcInd].Size, true), Format('%.0n', [Status.mb/(Arcs[ArcInd].Size/oneMB)*100]), ByteOrTB(Status.allsize, true)])
ProgressBar.Position:= round(ProgressBar.Max * Status.mb/trunc(Arcs[ArcInd].Size/oneMB))
end;
End;

Procedure MyTimerProc(h, msg, idevent, dwTime: Longword);
Begin
if WizardForm.CurPageID = wpInstalling then UpdateStatus(0);
End;

Procedure OnWndHook(Code: Integer; wParam: Word; lParam: TCWPSTRUCT);
Begin
if (Code = HC_ACTION) and (LoWord(lParam.msg) = WM_PAINT) then begin // подготовка данных для последующего отображения по таймеру
if (Status.name <> WizardForm.FileNameLabel.Caption) and (WizardForm.FileNameLabel.Caption <> '') then begin // имя файла, названия ярлыка и прочее
FileNameLabel.Caption:= WizardForm.FileNameLabel.Caption;
Status.name:= WizardForm.FileNameLabel.Caption; // начало извлечения или распаковки очередного файла
Case Status.stage of
SetupMessage(msgStatusExtractFiles): // этап извлечения файлов инсталлятором
Status.count:= Status.count +1; // кол-во файлов
End;
end;
if (Status.stage <> WizardForm.StatusLabel.Caption) and (WizardForm.StatusLabel.Caption <> '') then begin
StatusLabel.Caption:= WizardForm.StatusLabel.Caption;
Status.stage:= WizardForm.StatusLabel.Caption; // текущий этап установки
if Status.stage = SetupMessage(msgStatusRollback) then begin
WizardForm.StatusLabel.Hide; WizardForm.FileNameLabel.Hide; StatusInfo.Hide; ExtractFile.Hide; ProgressBar.Hide;
end;
end;
with WizardForm.ProgressGauge do begin
n:= (Max - Min)/1000
if n > 0 then Status.perc:= (Position-Min)/n; // 1000 процентов
end;
UpdateStatus(0);
end;
CallNextWNDPROC(WndHookID, Code, wParam, lParam) {освобождение события}
End;

// compsize: в Mb объём архива
// total_files: в int2 ? число файлов в архиве
// origsize: в Mb общий объём данных в архиве
// write: в Mb число записанных (распакованных из архива) на диск мегабайт
// read: в Mb число обработанных мегабайт, в int2 размер текущего архива
// filename: вызывается перед обработкой каждого файла



Function ArcDecode(Line: string): array of TArc; // разбор строки Archives
var tmp, cut: array of String; n, i: integer;
Begin
SetArrayLength(result,0); if Line <> '' then tmp:= StringToArray(Line,'|') else Exit;
for n:= 0 to GetArrayLength(tmp) - 1 do begin
if tmp[n][Length(tmp[n])] = '?' then Continue; // эта запись обрабатывается в AfterInstall: UnArc(...)
SetArrayLength(result, GetArrayLength(result) +1); i:= GetArrayLength(result) -1;
cut:= StringToArray(tmp[n],'>') // задачи, логика or and not наверное не будет работать
if GetArrayLength(cut) > 1 then result[i].task:= cut[1];
cut:= StringToArray(cut[0],'<') // компоненты
if GetArrayLength(cut) > 1 then result[i].comp:= cut[1];
cut:= StringToArray(cut[0],'/') // папка распаковки
if GetArrayLength(cut) > 1 then result[i].Dest:= cut[1] else result[i].Dest:= '{app}'; // по-умолчанию
if (ExtractFileDrive(ExpandENV(cut[0])) = '') and (ExpandENV(cut[0]) = cut[0]) then // строка вида Rus\*.arc
result[i].Path:= '{src}\'+ cut[0] else result[i].Path:= cut[0]; // остаток от исходной строки
result[i].Dest:= ExpandENV(result[i].Dest); result[i].Path:= ExpandENV(result[i].Path);
end;
End;

procedure CurStepChanged2(CurStep: TSetupStep);
begin
if CurStep = ssInstall then begin
StartInstall:= GetTickCount {время начала извлечения файлов}
WndHookID:= SetWindowsHookEx(WH_CALLWNDPROC, WrapCWPSTRUCTProc(@OnWndHook, 3), 0, GetCurrentThreadID); {установка SendMessage хука}
TimerID:= SetTimer(0, 0, 500 {полсекунды}, WrapTimerProc(@MyTimerProc, 4)); {установка таймера}
if not {#isFalse(SetupSetting("Uninstallable"))} then Status.count:= -1; // не считать файл unins000.exe
end;
if CurStep = ssPostInstall then
begin
StartInstall:= GetTickCount {время начала распаковки}

if UnPackError <> 0 then begin // Error occured, uninstall it then
if not {#isFalse(SetupSetting("Uninstallable"))} then // деинсталляция разрешёна
Exec(ExpandConstant('{uninstallexe}'), '/SILENT','', sw_Hide, ewWaitUntilTerminated, n); // откат установки из-за ошибки unarc.dll
WizardForm.caption:= SetupMessage(msgErrorTitle) +' - '+ cm('ArcBreak')
SetTaskBarTitle(SetupMessage(msgErrorTitle))
end else
SetTaskBarTitle(SetupMessage(msgSetupAppTitle));
//Вынес сюда, иначе возникали глюки
KillTimer(0, TimerID) {удаление таймера}
UnhookWindowsHookEx(WndHookID) {удаление SendMessage хука}
//Вынес чтоб нормально работал SIPrecomp
if UnPackError = 0 then
if PrecompFiles <> 0 then //если кол-во найденных файлов не равно 0, то работает ISPrecomp
begin
RecodePCF()
DeleteFile(ExpandConstant('{app}\Files.ini'))
WizardForm.StatusLabel.Caption:= FmtMessage(cm('ArcFinish'), [IntToStr(GetArrayLength(Arcs)), IntToStr(Status.count), ByteOrTB(Status.size*oneMB, true)]);
StatusInfo.Hide; ExtractFile.Hide; ProgressBar.Hide; //Скрываем надписи и пргрессбары
end else //Иначе просто все скрываем
begin
WizardForm.StatusLabel.Caption:= FmtMessage(cm('ArcFinish'), [IntToStr(GetArrayLength(Arcs)), IntToStr(Status.count), ByteOrTB(Status.size*oneMB, true)]);
StatusInfo.Hide; ExtractFile.Hide; ProgressBar.Hide;
end;
end;
end;

Procedure SetTexture(CurPageID: Integer); // на каждой странице своя картинка
Begin
WizardForm.Bevel1.Visible:= (WizardForm.CurPageID <> wpWelcome) and (WizardForm.CurPageID <> wpFinished);
WizardForm.Bevel1.Parent:= WizardForm.OuterNotebook.ActivePage
Texture.Parent:= WizardForm.InnerNotebook.ActivePage; Texture.SendToBack;
Texture.Visible:= CurPageID = wpInstalling; Texture2.Visible:= Texture.Visible;
End;

Procedure CurPageChanged1(CurPageID: Integer);
Begin
SetTexture(CurPageID)
if (CurPageID = wpFinished) and (UnPackError <> 0) then
begin // Extraction was unsuccessful (распаковщик вернул ошибку)
// Show error message
WizardForm.FinishedLabel.Font.Color:= $0000C0; // red (красный)
WizardForm.FinishedLabel.Height:= WizardForm.FinishedLabel.Height * 2;
WizardForm.FinishedLabel.Caption:= SetupMessage(msgSetupAborted) + #13#10#13#10 + msgError;
end;
End;

procedure WizardClose(Sender: TObject; var Action: TCloseAction);
Begin
Action:= caNone; // так надо
if Status.stage = cm('ArcTitle') then begin // распаковка на этапе ssPostInstall
UpdateStatus(1); // остановить таймер
if MsgBox(SetupMessage(msgExitSetupMessage), mbInformation, MB_YESNO) = IDYES then
CancelCode:= -127; // прервать распаковку
UpdateStatus(7); // обновить информацию
end else
MainForm.Close; // стандартное нажатие кнопки закрытия окна, отмены или Escape.
End;

procedure InitializeWizard1();
begin

ExtractTemporaryFile('1.bmp');
ExtractTemporaryFile('2.bmp');
ExtractTemporaryFile('3.bmp');
ExtractTemporaryFile('4.bmp');
ExtractTemporaryFile('5.bmp');
ExtractTemporaryFile('button.bmp');


NeedSize:= {#NeedSize};

BmpFile:= TBitmapImage.Create(WizardForm);
BmpFile.Bitmap.LoadFromFile(ExpandConstant('{tmp}\1.bmp'));
BmpFile.Top:= ScaleY(0);
BmpFile.Left:= ScaleX(0);
BmpFile.Width:= ScaleX(790);
BmpFile.Height:= ScaleY(533);
BmpFile.Stretch:= true;
BmpFile.Parent:= WizardForm.WelcomePage;

BmpFile:= TBitmapImage.Create(WizardForm);
BmpFile.Bitmap.LoadFromFile(ExpandConstant('{tmp}\2.bmp'));
BmpFile.Top:= ScaleY(0);
BmpFile.Left:= ScaleX(0);
BmpFile.Width:= ScaleX(790);
BmpFile.Height:= ScaleY(533);
BmpFile.Stretch:= true;
BmpFile.Parent:= WizardForm.SelectDirPage;

BmpFile:= TBitmapImage.Create(WizardForm);
BmpFile.Bitmap.LoadFromFile(ExpandConstant('{tmp}\3.bmp'));
BmpFile.Top:= ScaleY(0);
BmpFile.Left:= ScaleX(0);
BmpFile.Width:= ScaleX(790);
BmpFile.Height:= ScaleY(533);
BmpFile.Stretch:= true;
BmpFile.Parent:= WizardForm.SelectProgramGroupPage;

BmpFile:= TBitmapImage.Create(WizardForm);
BmpFile.Bitmap.LoadFromFile(ExpandConstant('{tmp}\4.bmp'));
BmpFile.Top:= ScaleY(0);
BmpFile.Left:= ScaleX(0);
BmpFile.Width:= ScaleX(790);
BmpFile.Height:= ScaleY(533);
BmpFile.Stretch:= true;
BmpFile.Parent:= WizardForm.InstallingPage;

BmpFile:= TBitmapImage.Create(WizardForm);
BmpFile.Bitmap.LoadFromFile(ExpandConstant('{tmp}\5.bmp'));
BmpFile.Top:= ScaleY(0);
BmpFile.Left:= ScaleX(0);
BmpFile.Width:= ScaleX(790);
BmpFile.Height:= ScaleY(533);
BmpFile.Stretch:= true
BmpFile.Parent:= WizardForm.FinishedPage;

WizardForm.ClientWidth:=ScaleX(790);
WizardForm.ClientHeight:=ScaleY(533);
WizardForm.Font.Color:=$ffffff;
WizardForm.Center;

with WizardForm do
begin
PageNameLabel.Hide;
PageDescriptionLabel.Hide;
WelcomeLabel1.Hide;
WelcomeLabel2.Hide;
DiskSpaceLabel.Hide;
SelectDirBitmapImage.Hide;
SelectDirBrowseLabel.Hide;
SelectDirLabel.Hide;
FinishedHeadingLabel.Hide;
FinishedLabel.Hide;
MainPanel.Hide;
FilenameLabel.Hide;
StatusLabel.Hide;
SelectStartMenuFolderLabel.Hide;
SelectStartMenuFolderBrowseLabel.Hide;
ReadyLabel.Hide;
end;

with WizardForm do
begin
InnerNotebook.Left := ScaleX(0);
InnerNotebook.Top := ScaleY(0);
InnerNotebook.Width := ScaleX(790);
InnerNotebook.Height := ScaleY(533);
OuterNotebook.Left := ScaleX(0);
OuterNotebook.Top := ScaleY(0);
OuterNotebook.Width := ScaleX(790);
OuterNotebook.Height := ScaleY(533);
end;

////////////////////// WelcomePage //////////////////////

WelcomeLabel1:= TLabel.Create(WizardForm);
with WelcomeLabel1 do
begin
Left:= ScaleX(50);
Top:= ScaleY(130);
Width:= ScaleX(650);
Height:= ScaleY(65);
AutoSize:= false;
Transparent:= true;
WordWrap:= true;
Font.Name:='Arial';
Font.Size:= 16;
Font.Color:=ClBlack; //"Вас приветствует"
Font.Style := [fsBold];
Parent:= WizardForm.WelcomePage;
Caption:= ExpandConstant('{cm:Welcome1}')+#13+('{#MyAppName}');
end;

WelcomeLabel2:=TLabel.Create(WizardForm);
with WelcomeLabel2 do
begin
Top:= ScaleY(230);
Left:= ScaleX(50);
Width:= ScaleX(260);
Height:= ScaleY(300);
AutoSize:= false;
WordWrap:= true;
Font.Name:= 'Georgia';
Font.Size:= 11
Font.Style := [fsBold, fsItalic];
Font.Color:=ClBlack;
Transparent:= true;
Parent:= WizardForm.WelcomePage;
Caption:= ExpandConstant('{cm:Welcome2}');
end;

////////////////////// WelcomePage //////////////////////

////////////////////// SelectDirPage //////////////////////

PageNameLabel1:= TLabel.Create(WizardForm);
with PageNameLabel1 do
begin
Left:= ScaleX(50);
Top:= ScaleY(155);
Width:= ScaleX(300);
Height:= ScaleY(30);
AutoSize:= False;
Font.Name:= 'Georgia'
Font.Size:= 15;
Font.Style:= [fsBold];
Font.Color:= ClWhite;
Transparent := True;
Parent:= WizardForm.SelectDirPage;
end;

PageDescriptionLabel1:= TLabel.Create(WizardForm);
with PageDescriptionLabel1 do
begin
Left:=ScaleX(50);
Top:= ScaleY(210);
Width:= ScaleX(320);
Height:= ScaleY(50);
Alignment := taCenter;
AutoSize:= False;
Font.Name:= 'Georgia'
Font.Size:= 10;
Font.Style:= [fsBold, fsItalic];
Font.Color:= ClWhite;
Wordwrap:= True;
Transparent := True;
Parent:= WizardForm.SelectDirPage;
end;

SelectDirBrowseLabel:= TLabel.Create(WizardForm);
with SelectDirBrowseLabel do
begin
Caption:= WizardForm.SelectDirBrowseLabel.Caption;
Left:= ScaleX(50);
Top:= ScaleY(250);
Width:= ScaleX(320);
Height:= ScaleY(50);
AutoSize:= False;
WordWrap:= True;
Font.Name:= 'Georgia'
Font.Size:= 10;
Font.Style:= [fsBold, fsItalic];
Font.Color:= ClWhite;
Transparent:= True;
Parent:= WizardForm.SelectDirPage;
end;

with WizardForm do
begin
DirBrowseButton.Top:= ScaleY(305);

DirEdit.Left:= ScaleX(120);
DirEdit.Top:= ScaleY(305);
DirEdit.Width:= ScaleX(460);
DirEdit.Font.Size:= 9;
DirEdit.Font.Style:= [fsBold, fsItalic];
DirEdit.Font.Name:= 'Georgia'
DirEdit.Color:=clGray;
end;

DirectX:= TCheckBox.Create(WizardForm);
with DirectX do
begin
Parent:= WizardForm.SelectDirPage;
Left:= ScaleX(65);
Top:= ScaleY(340);
Width:= ScaleX(14);
Height:= ScaleY(14);
TabOrder:= 0;
Checked:= False;
end;

DirectXLabel:= TLabel.Create(WizardForm);
with DirectXLabel do
begin
Caption:= ExpandConstant('{cm:DirectX}');
Left:= ScaleX(90);
Top:= ScaleY(340);
Width:= ScaleX(150);
Height:= ScaleY(13);
Font.Name:= 'Georgia';
Font.Size:= 8;
Font.Style:= [fsBold, fsItalic];
Font.Color:= ClBlue;
Transparent := True;
Parent:= WizardForm.SelectDirPage;
OnClick:= @DirectXLabelOnClick;
end;

Icons:= TCheckBox.Create(WizardForm);
with Icons do
begin
Parent:= WizardForm.SelectDirPage;
Left:= ScaleX(65);
Top:= ScaleY(360);
Width:= ScaleX(14);
Height:= ScaleY(14);
TabOrder:= 2;
Checked:= False;
end;

IconsLabel:= TLabel.Create(WizardForm);
with IconsLabel do
begin
Caption:=ExpandConstant('{cm:Icons}');
Left:= ScaleX(90);
Top:= ScaleY(360);
Width:= ScaleX(150);
Height:= ScaleY(13);
Font.Name:= 'Georgia';
Font.Size:= 8;
Font.Style:= [fsBold, fsItalic];
Font.Color:= ClBlue;
Transparent := True;
Parent:= WizardForm.SelectDirPage;
OnClick:= @IconsOnClick;
end;

NeedSpaceLabel:= TLabel.Create(WizardForm);
with NeedSpaceLabel do
begin
Parent:= WizardForm.SelectDirPage;
Left:= ScaleX(65);
Top:= ScaleY(420);
Width:= ScaleX(230);
Height:= ScaleY(13);

Font.Size:= 14;
Font.Style:= [fsBold, fsItalic];
Font.Color:= ClRed;
Transparent:= True;
end;

FreeSpaceLabel:= TLabel.Create(WizardForm);
with FreeSpaceLabel do
begin
Parent:= WizardForm.SelectDirPage;
Left:= ScaleX(65);
Top:= ScaleY(440);
Width:= ScaleX(230);
Height:= ScaleY(14);

Font.Size:= 14;
Font.Style:= [fsBold, fsItalic];
Font.Color:= ClGreen;
Transparent:= True;
end;

WizardForm.DirEdit.OnChange:= @GetFreeSpaceCaption;
WizardForm.DirEdit.Text:= WizardForm.DirEdit.Text + #0;

////////////////////// SelectDirPage //////////////////////

////////////////////// ProgrammGroupPage //////////////////////

PageNameLabel2:= TLabel.Create(WizardForm);
with PageNameLabel2 do
begin
Left:= ScaleX(65);
Top:= ScaleY(185);
Width:= ScaleX(350);
Height:= ScaleY(30);
AutoSize:= False;
Font.Name:= 'Georgia';
Font.Size:= 13;
Font.Style:= [fsBold];
Font.Color:= ClBlue;
Transparent := True;
Parent:= WizardForm.SelectProgramGroupPage;
end;

PageDescriptionLabel2:= TLabel.Create(WizardForm);
with PageDescriptionLabel2 do
begin
Left:=ScaleX(95);
Top:= ScaleY(215);
Width:= ScaleX(600);
Height:= ScaleY(50);
AutoSize:= False;
Font.Name:= 'Georgia'
Font.Size:= 10;
Font.Style:= [fsBold, fsItalic];
Font.Color:= ClBlue;
Wordwrap:= True;
Transparent := True;
Parent:= WizardForm.SelectProgramGroupPage;
end;

SelectStartMenuFolderBrowseLabel:=TLabel.Create(WizardForm)
with SelectStartMenuFolderBrowseLabel do
begin
Left:= ScaleX(120);
Top:= ScaleY(250);
Width:= ScaleX(600);
Height:= ScaleY(50);
AutoSize:= False;
WordWrap:= True;
Font.Name:= 'Georgia';
Font.Size:= 10;
Font.Style:= [fsBold, fsItalic];
Font.Color:= ClBlue;
WordWrap:=True
Transparent:=True
Caption:=ExpandConstant('{cm:StartMenuLbl}')
Parent:=WizardForm.SelectProgramGroupPage
end;

WizardForm.NoIconsCheck.Show;
WizardForm.NoIconsCheck.Left := ScaleX(65);
WizardForm.NoIconsCheck.Top := ScaleY(440);
WizardForm.NoIconsCheck.Width := ScaleX(13);
WizardForm.NoIconsCheck.Height := ScaleY(13);
WizardForm.NoIconsCheck.OnClick := @CheckStartMenuOnClick;
WizardForm.NoIconsCheck.Parent := WizardForm.SelectProgramGroupPage;

NoIconsLabel:= TLabel.Create(WizardForm);
with NoIconsLabel do
begin
Caption:=WizardForm.NoIconsCheck.Caption
Left:= ScaleX(90);
Top:= ScaleY(440);
Width:= ScaleX(150);
Height:= ScaleY(13);
Font.Name:= 'Georgia';
Font.Size:= 8;
Font.Style:= [fsBold, fsItalic];
Font.Color:= ClBlue;
Transparent := True;
Parent:= WizardForm.SelectProgramGroupPage
OnClick := @CheckNoIconsCheck;
end;

with WizardForm do
begin
GroupEdit.Left:= ScaleX(120);
GroupEdit.Top:= ScaleY(305);
GroupEdit.Width:= ScaleX(460);
GroupEdit.Font.Size:=9
GroupEdit.Font.Style:= [fsBold, fsItalic];
GroupEdit.Font.Name:= 'Georgia'

GroupBrowseButton.Top:= ScaleY(305);
end;

////////////////////// ProgrammGroupPage //////////////////////

////////////////////// InstallingPage //////////////////////

PageNameLabel3:= TLabel.Create(WizardForm);
with PageNameLabel3 do
begin
Left:= ScaleX(65);
Top:= ScaleY(185);
Width:= ScaleX(150);
Height:= ScaleY(20);
AutoSize:= False;
Font.Name:= 'Georgia';
Font.Size:= 14;
Font.Style:= [fsBold, fsItalic];
Font.Color:= ClWhite;
Transparent := True;
Parent:= WizardForm.InstallingPage;
end;

StatusLabel:= TLabel.Create(WizardForm);
with StatusLabel do
begin
Left:=ScaleX(95);
Top:= ScaleY(215);
Width:= ScaleX(600);
Height:= ScaleY(50);
AutoSize:= False;
Font.Name:= 'Georgia';
Font.Size:= 10;
Font.Style:= [fsBold, fsItalic];
Font.Color:= ClWhite; // Пажалуста подождите
Transparent := True;
Parent:= WizardForm.InstallingPage;
Caption:= ExpandConstant('{cm:Status}')
end;

FilenameLabel:= TLabel.Create(WizardForm);
with FilenameLabel do
begin
Left:= ScaleX(95);
Top:= ScaleY(275);
Width:= ScaleX(625);
Height:= ScaleY(20);
AutoSize:= False;
Font.Name:= 'Georgia'
Font.Size:= 10;
Font.Style:= [fsBold, fsItalic];
Font.Color:= ClWhite; //Идет распаковка
Transparent := True;
Parent:= WizardForm.InstallingPage;
end;

with WizardForm do
begin
ProgressGauge.Top:=ScaleY(310);
ProgressGauge.Left:=ScaleX(100);
ProgressGauge.Width:=ScaleX(590);
ProgressBar := TNewProgressBar.Create(WizardForm);
ProgressBar2:= TNewProgressBar.Create(WizardForm);
with ProgressBar do begin
Left := WizardForm.ProgressGauge.Left;
Top := WizardForm.ProgressGauge.Top + ScaleX(60);
Width := WizardForm.ProgressGauge.Width/2;
Height := WizardForm.ProgressGauge.Height;
Parent := WizardForm.InstallingPage;
Min := 0;
Max := GetArrayLength(Files);
Position := 0;
show;
with ProgressBar2 do begin
Left := WizardForm.ProgressGauge.Left + ScaleY(310);
Top := WizardForm.ProgressGauge.Top + ScaleX(60);
Width := 280;
Height := WizardForm.ProgressGauge.Height;
Parent := WizardForm.InstallingPage;
Min := 0;
Max := 100;
Position := 0;
show;
end;
end;
end;


////////////////////// InstallingPage //////////////////////

////////////////////// FinishedPage //////////////////////

FinishedHeadingLabel:=TLabel.Create(WizardForm);
with FinishedHeadingLabel do
begin
Left:= ScaleX(70);
Top:= ScaleY(130);
Width:= ScaleX(650);
Height:= ScaleY(65)
AutoSize:= false;
Alignment := taCenter;
WordWrap:= true;
Font.Name:='Georgia';
Font.Size:= 16;
Font.Color:=ClWhite;
Font.Style := [fsBold];
Transparent:= true;
Parent:= WizardForm.FinishedPage;
Caption:= ExpandConstant('{cm:Finished1}');
end;

FinishedLabel:= TLabel.Create(WizardForm);
with FinishedLabel do
begin
Top:= ScaleY(330);
Left:= ScaleX(70);
Width:= ScaleX(650);
Height:= ScaleY(200);
Alignment := taCenter;
AutoSize:= false;
WordWrap:= true;
Font.Name:= 'Georgia'
Font.Size:= 12;
Font.Style := [fsBold, fsItalic];
Font.Color:=ClWhite; // Установка завершена
Transparent:= true;
Parent:= WizardForm.FinishedPage;
Caption:= ExpandConstant('{cm:Finished2}')+#13#13+ExpandConstant('{cm:Finished3}');
end;
end;

////////////////////// FinishedPage //////////////////////

procedure CurPageChanged2(CurPageID: Integer);
begin
PageNameLabel1.Caption:= WizardForm.PageNameLabel.Caption;
PageDescriptionLabel1.Caption:= WizardForm.PageDescriptionLabel.Caption;
PageNameLabel2.Caption:= WizardForm.PageNameLabel.Caption;
PageDescriptionLabel2.Caption:= WizardForm.PageDescriptionLabel.Caption;
PageNameLabel3.Caption:= WizardForm.PageNameLabel.Caption;

if CurPageID=wpSelectProgramGroup then
begin
If WizardForm.FindComponent('NextButton') is TButton
then
TButton(WizardForm.FindComponent('NextButton')).Caption:='Установить';
end;
end;

//************************************************ [Начало - Текстуры кнопок] ***************************************************//

procedure ButtonLabelClick(Sender: TObject);
var
Button: TButton;
begin
ButtonImage[TLabel(Sender).Tag].Left := 0;
case TLabel(Sender).Tag of
bidBack: Button := WizardForm.BackButton;
bidNext: Button := WizardForm.NextButton;
bidCancel: Button := WizardForm.CancelButton;
bidDirBrowse: Button := WizardForm.DirBrowseButton;
bidGroupBrowse: Button := WizardForm.GroupBrowseButton;
else
Exit
end
Button.OnClick(Button);
end;

procedure ButtonLabelMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
if ButtonLabel[TLabel(Sender).Tag].Enabled then
ButtonImage[TLabel(Sender).Tag].Left := -ScaleX(ButtonWidth);
end;

procedure ButtonLabelMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
ButtonImage[TLabel(Sender).Tag].Left := 0;
end;

procedure LoadButtonImage(AButton: TButton; AButtonIndex: integer);
var
Image: TBitmapImage;
Panel: TPanel;
Labl: TLabel;

begin
Panel := TPanel.Create(WizardForm);
Panel.Left := AButton.Left;
Panel.Top := AButton.Top;
Panel.Width := AButton.Width;
Panel.Height := AButton.Height;
Panel.Tag := AButtonIndex;
Panel.Parent := AButton.Parent;
ButtonPanel[AButtonIndex] := Panel;

Image := TBitmapImage.Create(WizardForm);
Image.Width := ScaleX(160);
Image.Height := ScaleY(23);
Image.Enabled := False;
Image.Bitmap.LoadFromFile(ExpandConstant('{tmp}\button.bmp'));
Image.Stretch := True;
Image.Parent := Panel;
ButtonImage[AButtonIndex] := Image;

with TLabel.Create(WizardForm) do begin
Tag := AButtonIndex;
Parent := Panel;
Width := Panel.Width;
Height := Panel.Height;
Transparent := True;
OnClick := @ButtonLabelClick;
OnDblClick := @ButtonLabelClick;
OnMouseDown := @ButtonLabelMouseDown;
OnMouseUp := @ButtonLabelMouseUp;
end;

Labl := TLabel.Create(WizardForm);
Labl.Autosize := True;
Labl.Alignment := taCenter;
Labl.Tag := AButtonIndex;
Labl.Transparent := True;
Labl.Font.Color := clYellow;
Labl.Font.Style := [fsBold];
Labl.Caption := AButton.Caption;
Labl.OnClick := @ButtonLabelClick;
Labl.OnDblClick := @ButtonLabelClick;
Labl.OnMouseDown := @ButtonLabelMouseDown;
Labl.OnMouseUp := @ButtonLabelMouseUp;
Labl.Parent := Panel;
ButtonLabel[AButtonIndex] := Labl;
end;

procedure UpdateButton(AButton: TButton;AButtonIndex: integer);
begin
ButtonLabel[AButtonIndex].Caption := AButton.Caption;
ButtonPanel[AButtonIndex].Visible := AButton.Visible;
ButtonLabel[AButtonIndex].Enabled := Abutton.Enabled;
end;

procedure InitializeWizard2();
begin
WizardForm.BackButton.SetBounds(WizardForm.ClientWidth - ScaleX(8) * 37,
WizardForm.ClientHeight - ScaleY(ButtonHeight) * 2, ScaleX(ButtonWidth), ScaleY(ButtonHeight));

WizardForm.NextButton.SetBounds(WizardForm.ClientWidth - ScaleX(8) * 26,
WizardForm.ClientHeight - ScaleY(ButtonHeight) * 2, ScaleX(ButtonWidth), ScaleY(ButtonHeight));

WizardForm.CancelButton.SetBounds(WizardForm.ClientWidth - ScaleX(8)* 15,
WizardForm.ClientHeight - ScaleY(ButtonHeight) * 2, ScaleX(ButtonWidth), ScaleY(ButtonHeight));

WizardForm.DirBrowseButton.SetBounds(WizardForm.ClientWidth - ScaleX(5) * 30,
WizardForm.ClientHeight - ScaleY(ButtonHeight) * 10, ScaleX(ButtonWidth), ScaleY(ButtonHeight));

WizardForm.GroupBrowseButton.SetBounds(WizardForm.ClientWidth - ScaleX(5) * 30,
WizardForm.ClientHeight - ScaleY(ButtonHeight) * 10, ScaleX(ButtonWidth), ScaleY(ButtonHeight));

ExtractTemporaryFile('1.bmp')
LoadButtonImage(WizardForm.BackButton,bidBack)
LoadButtonImage(WizardForm.NextButton,bidNext)
LoadButtonImage(WizardForm.CancelButton,bidCancel)
LoadButtonImage(WizardForm.DirBrowseButton,bidDirBrowse)
LoadButtonImage(WizardForm.GroupBrowseButton,bidGroupBrowse)
end;

procedure CurPageChanged3(CurPageID: Integer);
begin

UpdateButton(WizardForm.BackButton,bidBack)
UpdateButton(WizardForm.NextButton,bidNext)
UpdateButton(WizardForm.CancelButton,bidCancel)

ButtonLabel[bidBack].Left := ButtonPanel[bidBack].Width div 2 - ButtonLabel[bidBack].Width div 2;
ButtonLabel[bidBack].Top := ButtonPanel[bidBack].Height div 2 - ButtonLabel[bidBack].Height div 2;
ButtonLabel[bidNext].Left := ButtonPanel[bidNext].Width div 2 - ButtonLabel[bidNext].Width div 2;
ButtonLabel[bidNext].Top := ButtonPanel[bidNext].Height div 2 - ButtonLabel[bidNext].Height div 2;
ButtonLabel[bidCancel].Left := ButtonPanel[bidCancel].Width div 2 - ButtonLabel[bidCancel].Width div 2;
ButtonLabel[bidCancel].Top := ButtonPanel[bidCancel].Height div 2 - ButtonLabel[bidCancel].Height div 2;
ButtonLabel[bidDirBrowse].Left := ButtonPanel[bidDirBrowse].Width div 2 - ButtonLabel[bidDirBrowse].Width div 2;
ButtonLabel[bidDirBrowse].Top := ButtonPanel[bidDirBrowse].Height div 2 - ButtonLabel[bidDirBrowse].Height div 2;
ButtonLabel[bidGroupBrowse].Left := ButtonPanel[bidGroupBrowse].Width div 2 - ButtonLabel[bidGroupBrowse].Width div 2;
ButtonLabel[bidGroupBrowse].Top := ButtonPanel[bidGroupBrowse].Height div 2 - ButtonLabel[bidGroupBrowse].Height div 2;

if CurPageID = wpSelectDir then
begin
GetNeedSpaceCaption;

if FreeMB < NeedSize then
begin

end;
end;
end;

//************************************************ [Конец - Текстуры кнопок] ***************************************************//

//************************************************ [Начало - Панель] ***************************************************//

Procedure InitializeWizard3();
Var
CurPageID: Integer;
begin
Welcome := TLabel.Create(WizardForm);
Welcome.Top := ScaleY(94);
Welcome.Left := ScaleX(35);
Welcome.Caption := 'Приветствие';
Welcome.Transparent := True;
Welcome.Font.Size := 12;
Welcome.Font.Name := 'Arial';
Welcome.Font.Style:= [fsBold];

Parameters := TLabel.Create(WizardForm);
Parameters.Top := ScaleY(94);
Parameters.Left := ScaleX(201);
Parameters.Caption:= 'Параметры';
Parameters.Transparent := True;
Parameters.Font.Size := 12;
Parameters.Font.Name := 'Arial';
Parameters.Font.Style:= [fsBold];

StartMenu := TLabel.Create(WizardForm);
StartMenu.Top := ScaleY(94);
StartMenu.Left := ScaleX(355);
StartMenu.Caption := 'Меню "Пуск"';
StartMenu.Transparent := True;
StartMenu.Font.Size := 12;
StartMenu.Font.Name := 'Arial';
StartMenu.Font.Style:= [fsBold];

Installing := TLabel.Create(WizardForm);
Installing.Top := ScaleY(94);
Installing.Left := ScaleX(520);
Installing.Caption := 'Установка';
Installing.Transparent := True;
Installing.Font.Size := 12;
Installing.Font.Name := 'Arial';
Installing.Font.Style:= [fsBold];


Finish := TLabel.Create(WizardForm);
Finish.Left := 400;
Finish.Top := ScaleY(94);
Finish.Left := ScaleX(670);
Finish.Caption := 'Завершение';
Finish.Transparent := True;
Finish.Font.Size := 12;
Finish.Font.Name := 'Arial';
Finish.Font.Style:= [fsBold];
end;

procedure CurPageChanged4(CurPageID: Integer);
begin
Welcome.Font.Color := -16777777;
Parameters.Font.Color := -16777777;
StartMenu.Font.Color := -16777777;
Installing.Font.Color := -16777777;
Finish.Font.Color := -16777777;


if (CurPageID= wpWelcome)or(CurPageID= wpSelectDir)or (CurPageID= wpSelectProgramGroup)or(CurPageID= wpInstalling)or(CurPageID= wpFinished) then
Welcome.Parent := DetectPage(CurPageID);
Parameters.Parent := DetectPage(CurPageID);
StartMenu.Parent := DetectPage(CurPageID);
Installing.Parent := DetectPage(CurPageID);
Finish.Parent := DetectPage(CurPageID);

if CurPageID = wpWelcome then
begin
Welcome.Font.Color := clGreen;
end;

if CurPageID = wpSelectDir then
begin
Parameters.Font.Color := clGreen;
end;

if CurPageID = wpSelectProgramGroup then
begin
StartMenu.Font.Color := clGreen;
end;

if CurPageID = wpInstalling then
begin
Installing.Font.Color := clGreen;
end;

if CurPageID = wpFinished then
begin
Finish.Font.Color := clGreen;
end;
end;

//************************************************ [Конец - Панель] ***************************************************//



//************************************************ [Начало - Скин] ***************************************************//

procedure LoadSkin(lpszPath: {#PStr}; lpszIniFileName: {#PStr});
external 'LoadSkin@files:isskin.dll stdcall delayload setuponly';

procedure LoadSkinUninst(lpszPath: {#PStr}; lpszIniFileName: {#PStr});
external 'LoadSkin@{tmp}\isskin.dll stdcall delayload uninstallonly';

procedure UnloadSkin();
external 'UnloadSkin@files:isskin.dll stdcall delayload setuponly';

procedure UnloadSkinUninst();
external 'UnloadSkin@{tmp}\isskin.dll stdcall delayload uninstallonly';

function ShowWindow(hWnd: Integer; uType: Integer): Integer;
external 'ShowWindow@user32.dll stdcall';



function InitializeUninstall(): Boolean;
begin
FileCopy(ExpandConstant('{app}\isskin.dll'), ExpandConstant('{tmp}\isskin.dll'), True);
Result := True;
end;

procedure DeinitializeUninstall();
begin
UnloadSkinUninst();
end;

//************************************************ [Конец - Скин] ***************************************************//

Procedure InitializeWizard5();
Begin
// Create controls to show extended info
PrecompFiles:=0
StatusLabel:= CreateLabel(WizardForm.InstallingPage,false,false,true,'',[],0,0,0,0,0, WizardForm.StatusLabel);
StatusLabel.Font.Name:= 'Arial'
StatusLabel.Font.Size:= 10;
StatusLabel.Font.Style:= [fsBold];
StatusLabel.Left:= ScaleX(100);
StatusLabel.Top:= ScaleY(245);
StatusLabel.Width:= ScaleX(625);
StatusLabel.Height:= ScaleY(20)

FileNameLabel:= CreateLabel(WizardForm.InstallingPage,false,false,true,'',[],0,0,0,0,0, WizardForm.FileNameLabel);
FileNameLabel.Font.Name:= 'Arial'
FileNameLabel.Font.Size:= 10;
FileNameLabel.Font.Style:= [fsBold, fsItalic];
FileNameLabel.Left:= ScaleX(100);
FileNameLabel.Top:= ScaleY(275);
FileNameLabel.Width:= ScaleX(625);
FileNameLabel.Height:= ScaleY(20)

WizardForm.StatusLabel.Top:= WizardForm.ProgressGauge.Top; WizardForm.FileNameLabel.Top:= WizardForm.ProgressGauge.Top; // прячем под прогрессбар, тогда все события WM_PAINT перехватываются
with WizardForm.ProgressGauge do begin
StatusInfo:= CreateLabel(WizardForm.InstallingPage, false, true, true, '', [], 0, 0, Top + ScaleY(32), Width, 0, Nil);
StatusInfo.Font.Name:= 'Arial'
StatusInfo.Font.Size:= 10;
StatusInfo.Font.Style:= [fsBold, fsItalic];
StatusInfo.Left:= ScaleX(100);
StatusInfo.Height:= ScaleY(20)

ProgressBar := TNewProgressBar.Create(WizardForm);
ProgressBar.SetBounds(Left, StatusInfo.Top + StatusInfo.Height + ScaleY(16), Width, Height);
ProgressBar.Parent := WizardForm.InstallingPage;
ProgressBar.max := 65536;
ProgressBar.Hide; // будет показан при обработке нескольких архивов

ExtractFile:= CreateLabel(WizardForm.InstallingPage, false, true, true, '', [], 0, 0, ProgressBar.Top + ScaleY(32), Width, 0, Nil);
ExtractFile.Font.Name:= 'Arial'
ExtractFile.Font.Size:= 10;
ExtractFile.Font.Style:= [fsBold, fsItalic];
ExtractFile.Left:= ScaleX(100);
ExtractFile.Height:= ScaleY(20)
end;
WizardForm.OnClose:= @WizardClose // позволяет прервать распаковку архивов стандартными способами
// фоновая графика
Texture:= TBitmapImage.Create(WizardForm);
Texture.SetBounds(-WizardForm.InnerNotebook.Left, -WizardForm.InnerNotebook.Top, WizardForm.ClientWidth, WizardForm.ClientHeight);
GradientFill(Texture, BackColor, EndColor); // вместо градиента можно загрузить картинку
Texture2:= TBitmapImage.Create(WizardForm);
Texture2.SetBounds(0, 0, WizardForm.ClientWidth, WizardForm.ClientHeight);
Texture2.Parent:= WizardForm.InnerPage;
Texture2.Bitmap:= Texture.Bitmap;
End;

procedure CurStepChanged3(CurStep: TSetupStep);
begin
if CurStep = ssPostInstall then RecodePCF;
end;

procedure CurStepChanged4(CurStep: TSetupStep);
begin
if CurStep = ssPostInstall then RecodeOgg;
end;

procedure DeinitializeSetup();
begin
KillTimer( 0, TimerID );
ShowWindow(StrToInt(ExpandConstant('{wizardhwnd}')), 0);
UnloadSkin();

end;

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

procedure CurStepChanged(CurStep: TSetupStep);
begin
CurStepChanged1(CurStep);
CurStepChanged2(CurStep);
CurStepChanged3(CurStep);
CurStepChanged4(CurStep);
end;



Procedure InitializeWizard();
begin
InitializeWizard1();
InitializeWizard2();
InitializeWizard3();
InitializeWizard5();
end;
[/more]
Автор: troyan90
Дата сообщения: 06.08.2010 17:14
подскажите можно ли раскасить TFolderTreeView.
я поставил к нему Color:=clred;
цвет не поменялся. но и ошибки никакой нету.
Автор: ChanVS
Дата сообщения: 06.08.2010 17:23
troyan90
У меня DirEdit.Color:=clGray; для выбора директории!
Автор: troyan90
Дата сообщения: 06.08.2010 17:29
это совсем разные вещи. DirEdit это TNewEdit вроде. а я спрашиваю про TFolderTreeView
Автор: ChanVS
Дата сообщения: 06.08.2010 17:32
troyan90
Дерево каталогов ?
Тогда не знаю!

Добавлено:
troyan90
Ты сделай такого плана
WelcomeLabel2:=TLabel.Create(WizardForm);
with WelcomeLabel2 do
begin
Top:= ScaleY(230);
Left:= ScaleX(50);
Width:= ScaleX(260);
Height:= ScaleY(300);
AutoSize:= false;
WordWrap:= true;
Font.Name:= 'Georgia';
Font.Size:= 11
Font.Style := [fsBold, fsItalic];
Font.Color:=ClRed;
Transparent:= true;
Parent:= WizardForm.WelcomePage;

Добавлено:
Всем спасибо!
Автор: troyan90
Дата сообщения: 06.08.2010 17:39
ChanVS
о чем это ты. как я через лейбл сделаю
это
http://img1.immage.de/0608e906.08.png
Автор: StalkMent
Дата сообщения: 06.08.2010 18:19
ChanVS,

Цитата:
И еще как создать пробел между:

russian.StatusInfo=файлов: %1%2, %3%% выполнено, осталось ждать %4
Просто ставь пробел.

Автор: JohnDes
Дата сообщения: 06.08.2010 18:48
Есть скрипт
[more]
[Files]
Source: AutoRunFiles\clock.avi; DestDir: {tmp}; Flags: dontcopy
[Code]
const
AviFrameWidth = 320; // ширина кадра
AviFrameHeight = 450; // высота кадра

var
CommandString: String;
FileName: String;
AviFrameTop: Integer;
AviFrameLeft: Integer;

function mciSendString(lpstrCommand: string; lpstrReturnString: PChar; uReturnLength:integer; hwndCallback:integer):integer;
external 'mciSendStringA@winmm.dll stdcall';

function GetSystemMetrics(nIndex:Integer):Integer;
external 'GetSystemMetrics@user32.dll stdcall';

procedure InitializeWizard();
begin
ExtractTemporaryFile(ExpandConstant('clock.avi'));
FileName:= ExpandConstant('{tmp}\clock.avi');
AviFrameTop:= GetSystemMetrics(18) / 2 - AviFrameHeight / 2;
AviFrameLeft:= GetSystemMetrics(47) / 2 - AviFrameWidth / 2;
end;

procedure CurStepChanged(CurStep: TSetupStep);
begin
if CurStep=ssInstall then
begin
CommandString:= 'Open ' + FileName + ' type AVIVideo alias AVIFile parent ' + IntToStr(AutoRun.Handle) + ' style child';
mciSendString(CommandString, '', 0, 0);

CommandString:= 'put AVIFile window at ' +
IntToStr(AviFrameLeft) + ' ' + IntToStr(AviFrameTop) + ' ' +
IntToStr(AviFrameWidth) + ' ' + IntToStr(AviFrameHeight);
mciSendString(CommandString, '', 0, 0);

//CommandString:= 'Play AVIFile fullscreen'; // полноэкранный режим
CommandString:= 'Play AVIFile repeat';
mciSendString(CommandString, '', 0, 0);
end;
end;

procedure DeinitializeSetup();
begin
CommandString:= 'Close AVIFile'; // закрываем при выходе
mciSendString(CommandString, '', 0, 0);
end;
[/more]
Помогите сделать так, чтобы нужно было указать не относительные параметры, а (забыл как называется)
Примерно так ScaleX(),ScaleY(),ScaleX(),ScaleY() .
Автор: Profrager
Дата сообщения: 06.08.2010 18:54
JohnDes

Цитата:
(забыл как называется)
абсолютные.

вместо
Код: AviFrameTop:= GetSystemMetrics(18) / 2 - AviFrameHeight / 2;
AviFrameLeft:= GetSystemMetrics(47) / 2 - AviFrameWidth / 2;
Автор: bambarbio
Дата сообщения: 06.08.2010 21:00

Цитата:
Русская справка к версии 5.0.x, автор перевода BagIra (зеркало) | cкачать в .chm формате

Может ктонибудь дать новую ссылку на этот файл?
Автор: John_White
Дата сообщения: 06.08.2010 21:03
bambarbio

Цитата:
Может ктонибудь дать новую ссылку на этот файл?

http://sabbathblacklab.narod.ru/rus2/is5hlp.rar
PS
Даж не открывал Америку...
Автор: bambarbio
Дата сообщения: 06.08.2010 21:52

Цитата:
John_White

Большое спасибо!
Автор: JohnDes
Дата сообщения: 06.08.2010 23:08
Profrager
Спасибо.

Помогите правильно дописать кусок скрипта.
Нужно сделать, чтобы при нажатии на кнопку воспроизводилось видео (уже сделал), и при повторном нажатии останавливалось (выгружалось).
[more]
procedure VideoBtnClick(hBtn:HWND);
begin
sndPlaySound(ExpandConstant('{tmp}\click.wav'), $0001);
AviFrameTop:= ScaleY(48);
AviFrameLeft:= ScaleX(18);

CommandString:= 'Open ' + FileName + ' type AVIVideo alias AVIFile parent ' + IntToStr(AutoRun.Handle) + ' style child';
mciSendString(CommandString, '', 0, 0);

CommandString:= 'put AVIFile window at ' +IntToStr(AviFrameLeft) + ' ' + IntToStr(AviFrameTop) + ' ' +IntToStr(AviFrameWidth) + ' ' + IntToStr(AviFrameHeight);
mciSendString(CommandString, '', 0, 0);

CommandString:= 'Play AVIFile repeat';
mciSendString(CommandString, '', 0, 0);
end;
[/more]
Автор: Profrager
Дата сообщения: 06.08.2010 23:26
JohnDes
[more]
Код: procedure VideoBtnClick(hBtn:HWND);
begin
sndPlaySound(ExpandConstant('{tmp}\click.wav'), $0001);

Trigger:=Trigger xor 1;
if Trigger=1 then begin
AviFrameTop:= ScaleY(48);
AviFrameLeft:= ScaleX(18);

CommandString:= 'Open ' + FileName + ' type AVIVideo alias AVIFile parent ' + IntToStr(AutoRun.Handle) + ' style child';
mciSendString(CommandString, '', 0, 0);

CommandString:= 'put AVIFile window at ' +IntToStr(AviFrameLeft) + ' ' + IntToStr(AviFrameTop) + ' ' +IntToStr(AviFrameWidth) + ' ' + IntToStr(AviFrameHeight);
mciSendString(CommandString, '', 0, 0);

CommandString:= 'Play AVIFile repeat';
mciSendString(CommandString, '', 0, 0);
end else begin
mciSendString('Close AVIFile','',0,0);
end;
end;
Автор: JohnDes
Дата сообщения: 07.08.2010 00:11
Profrager
При нажатии на кнопку видео проигрывается, и при повторном не выключается
Возможно ли прописать вместо
Код: Trigger:=Trigger xor 1;
Автор: Profrager
Дата сообщения: 07.08.2010 06:55
JohnDes
смысл один и тот же, просто видимо mciSendString('Close AVIFile','',0,0); не останавливает воспроизведение

Добавлено:
Возможно тебе поможет mciSendString('stop AVIFile','',0,0); перед mciSendString('Close AVIFile','',0,0);

Добавлено:
или же ты сделал локальную переменную Trigger, в этой же функции, потому и не работает)

Страницы: 1234567891011121314151617181920212223

Предыдущая тема: Skype (Часть 3)


Форум Ru-Board.club — поднят 15-09-2016 числа. Цель - сохранить наследие старого Ru-Board, истории становления российского интернета. Сделано для людей.