PDA

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


Страниц : 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

solvador
26-11-2009, 23:11
Цитировать » Можно пример скрипта в котором эти кнопки можно было бы разместить на нескольких страницах с доп.задачами. Если это возможно. В данном виде кнопка "Всё" отображается только на последней странице, а кнопка "Ничего" есть на всех.
Заранее благодарен.

Serega
26-11-2009, 23:25
В данном виде кнопка "Всё" отображается только на последней странице, а кнопка "Ничего" есть на всех. »
Вы заблуждаетесь, видимо вы что-то поменяли в скрипте...
Именно в данном виде, кнопки отображаются на странице компонентов (Parent:= WizardForm.SelectComponentsPage;).

solvador
26-11-2009, 23:34
Serega, я не совсем может правильно выразился. У меня несколько доп. страниц Page1, Page2 с задачами. Если скрипт привязать к одной из них, то всё работает, обе кнопки на месте. Если привязать скрипт ещё на другую страницу, то кнопка "Всё" имеется только на Page1 , на Page2 её нет, только кнопка "Ничего".
Могу в личку скрипт кинуть, чтобы понятнее было.

ЗЫ Вместо Parent:= WizardForm.SelectComponentsPage; я соответственно вписал свои страницы Parent:= Page1.Surface;. И в procedure btnClick так же внёс нужные правки.

YURSHAT
26-11-2009, 23:38
Serega, а есть возмозножность сделать так, чтобы мое созданное сообщение выводилось раньше стандартного. Например это function NextButtonClick(CurPageID: Integer): Boolean;
var
Path,s: String;
FreeMB, TotalMB: Cardinal;
begin
Result:= True;
if CurPageID = wpSelectDir then
begin
Path:= ExtractFileDrive(WizardForm.DirEdit.Text);
GetSpaceOnDisk(Path, True, FreeMB, TotalMB);
if FreeMB < (NeedSize*1024) then
begin
if FreeMB>1024 then
begin
s:='Для установки приложения необходимо '+ IntTostr(NeedSize)+ ' GB,'#13+'а на выбранном Вами диске доступно только '+ floatToStr(round(FreeMB/1024*100)/100) + ' GB!'
end
else s:='Для установки приложения необходимо '+ IntTostr(NeedSize)+ ' GB,'#13+'а на выбранном Вами диске доступно только '+ + IntToStr(FreeMB)+' MB';
MsgBox(s, mbCriticalError, MB_OK)
Result := False;
end;
end;

Serega
26-11-2009, 23:59
я не совсем может правильно выразился »
У вас в коде где-то ошибка. Надо смотреть.

а есть возмозножность сделать так, чтобы мое созданное сообщение »

....................................................
if CurPageID = wpSelectDir then
begin
// здесь вставьте ваше сообщение...
.....................................................

solvador
27-11-2009, 00:47
Serega, подвела меня моя невнимательность. У меня просто кнопки друг на друга накладывались. Исправил, всё работает.
Спасибо. За скрипт и за помощь.

STRELOK
27-11-2009, 09:50
Народ помогите последние время IS стал выдавать такую ошибку http://pic.ipicture.ru/uploads/091127/vWp0Y5eVdo.jpg

Кому не сложно соедините этот скрипт

[Setup]
AppName=Call of Duty Modern Warfare 2
AppVerName=Call of Duty Modern Warfare 2
DefaultDirName={pf}\Call of Duty Modern Warfare 2
DefaultGroupName=Call of Duty Modern Warfare 2
UsePreviousAppDir=false
DirExistsWarning=no
ShowLanguageDialog=yes
OutputBaseFilename=setup
OutputDir=/сod6
VersionInfoCopyright=kid#why? ^_-
WizardImageFile=WizardImage1231.bmp
WizardSmallImageFile=small11.bmp
AppCopyRight=kid#why? ^_-
Compression=lzma/ultra64
InternalCompressLevel=ultra64
SolidCompression=true
DiskSpanning=yes
DiskSliceSize=1000000000
SlicesPerDisk=2
SetupIconFile=Icon.ico

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

[CustomMessages]
eng.ArcBreak=Installation cancelled!
eng.ExtractedInfo=Extracted %1 Mb of %2 Mb
eng.ArcInfo=Archive: %1 of %2
eng.ArcTitle=Extracting FreeArc archive
eng.ArcError=Decompression failed with error code %1
eng.ArcFail=Decompression failed!
eng.AllProgress=Overall extraction progress: %1%%
eng.ArcBroken=Archive %1 is damaged%nor not enough free space.
eng.Extracting=Extracting: %1
eng.taskbar=%1%%, %2 remains
eng.remains=Remaining time: %1
eng.LongTime=at no time
eng.ending=ending
eng.hour= hours
eng.min= mins
eng.sec= secs

rus.ArcBreak=Установка прервана!
rus.ExtractedInfo=Распаковано %1 Мб из %2 Мб
rus.ArcInfo=Архив: %1 из %2
rus.ArcTitle=Распаковка архивов FreeArc
rus.ArcError=Распаковщик FreeArc вернул код ошибки: %1
rus.ArcFail=Распаковка не завершена!
rus.AllProgress=Общий прогресс распаковки: %1%%
rus.ArcBroken=Возможно, архив %1 повреждён%nили недостаточно места на диске назначения.
rus.Extracting=Распаковывается: %1
rus.taskbar=%1%%, жди %2
rus.remains=Осталось ждать %1
rus.LongTime=вечно
rus.ending=завершение
rus.hour= часов
rus.min= мин
rus.sec= сек

[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"
Name: task1; Description: Доп. программное обеспечение
Name: task1\task2; Description: DirectX
Name: task1\task3; Description: Visual C++

[Icons]
Name: "{group}\Call of Duty Modern Warfare 2"; Filename: "{app}\iw4sp.exe"; WorkingDir: "{app}"; Parameters: Call of Duty Modern Warfare 2;
Name: "{userdesktop}\Call of Duty Modern Warfare 2"; Filename: "{app}\iw4sp.exe"; WorkingDir: "{app}"; Tasks: desktopicon; Parameters: Call of Duty Modern Warfare 2;
Name: "{group}\{cm:UninstallProgram,Call of Duty Modern Warfare 2}"; Filename: "{uninstallexe}"

[Run]
Filename: {src}\DirectX\dxsetup.exe; Parameters: /silent; StatusMsg: Идет установка дополнительных программ...; Tasks: task1\task2; Flags: waituntilterminated
Filename: {src}\Redist\vcredist_x86.exe; Parameters: /Q; StatusMsg: Идет установка дополнительных программ...; Tasks: task1\task3; Flags: waituntilterminated

[Files]
;Source: *.arc; DestDir: {app}; Flags: nocompression deleteafterinstall
Source: unarc.dll; DestDir: {tmp}; Flags: dontcopy deleteafterinstall
Source: compiler:InnoCallback.dll; DestDir: {tmp}; Flags: dontcopy
Source: logo1.bmp; DestDir: {tmp}; Flags: dontcopy


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

[Code]
// Страница приветствия ---------------------------------------------------------------------------------------------------------------------------------

procedure InitializeWizard2();
var
WLabel1, WLabel2: TLabel;
//FLabel1, FLabel2: TLabel;
bottom_img:TBitmapImage;
BmpFile: TBitmapImage;
FinishedHeadingLabel ,FinishedLabel:TLabel;

begin
WizardForm.WelcomeLabel1.Hide;
WizardForm.WelcomeLabel2.Hide;
WizardForm.WizardBitmapImage.Width := 497;
WizardForm.WizardBitmapImage.Height := 314;
WizardForm.Bevel1.Hide;
WizardForm.FinishedHeadingLabel.Hide;
WizardForm.FinishedLabel.Hide;
begin

ExtractTemporaryFile('logo1.bmp');
bottom_img:= TBitmapImage.Create(WizardForm);
bottom_img.Bitmap.LoadFromFile(ExpandConstant('{tmp}\logo1.bmp'));
bottom_img.SetBounds(5, 320, 128, 30); {первые 2 параметра - координаты левогого верхнего угла по горизонтали и вертикали, дальше ширина и высота, до которой растянуть}
bottom_img.Parent:= WizardForm;
bottom_img.Stretch:= True;
end;

WLabel1 := TLabel.Create(WizardForm);
WLabel1.Left := ScaleX(165);
WLabel1.Top := ScaleY(45);
WLabel1.Width := ScaleX(321);
WLabel1.Height := ScaleY(54);
WLabel1.AutoSize := False;
WLabel1.WordWrap := True;
WLabel1.Font.Size := 13;
WLabel1.Font.Style := [fsBold];
WLabel1.Font.Color:= clBlack;
WLabel1.Font.name:='Constantia';
WLabel1.ShowAccelChar := False;
WLabel1.Caption := WizardForm.WelcomeLabel1.Caption;
WLabel1.Transparent := True;
WLabel1.Parent := WizardForm.WelcomePage;
WLabel1.Alignment:= taCenter;

WLabel2:=TLabel.Create(WizardForm);
WLabel2.Top := ScaleY(140);
WLabel2.Left := ScaleX(165);
WLabel2.Width := ScaleX(301);
WLabel2.Height := ScaleY(234);
WLabel2.AutoSize := False;
WLabel2.WordWrap := True;
WLabel2.Alignment:= taCenter;
WLabel2.Font.Color:= clBlack;
WLabel2.Font.Size := 9;
//WLabel2.Font.Style := [fsBold];
WLabel2.ShowAccelChar := False;
WLabel2.Caption := WizardForm.WelcomeLabel2.Caption;
WLabel2.Transparent := True;
WLabel2.Parent := WizardForm.WelcomePage;





FinishedHeadingLabel:=TLabel.Create(WizardForm);
with FinishedHeadingLabel do
begin
Left:= ScaleX(165);
Top:= ScaleY(30);
Width:= ScaleX(330);
Height:= ScaleY(74);
AutoSize:= false;
WordWrap:= true;
Alignment:= taCenter;
Font.Size:= 13;
Font.Color:=ClBlack
Font.Style:=[fsBold];
Font.Name:= 'Constantia';

Transparent:= true;
Parent:= WizardForm.FinishedPage;
Caption:= WizardForm.FinishedHeadingLabel.Caption;
end;


FinishedLabel:= TLabel.Create(WizardForm);
with FinishedLabel do
begin
Left:= ScaleX(210);
Top:= ScaleY(145);
Width:= ScaleX(250);
Height:= ScaleY(250);
AutoSize:= false;
WordWrap:= true;
Transparent:= false;
Font.Size:= 9;
Alignment:= taCenter;
Font.Color:=ClBlack
// Font.Style:=[fsBold, fsItalic];
// Font.Name:= 'Constantia';
Parent:= WizardForm.FinishedPage;
Caption:= 'Игра {#SetupSetting("AppName")} установлена на Ваш компьютер.' +#10#13#10 + 'Нажмите «Завершить», чтобы выйти из программы установки.'
end;



//////////////////Картинка вверху//////////////////////////
begin
with WizardForm do begin
with MainPanel do
Height := Height - 0;
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;


begin
//Извлечение изображения
//Динамическое выделение памяти под изображение (BMP-файла)
BmpFile:= TBitmapImage.Create(WizardForm);
//Загрузка изображения из директории, в которую извлекали файл
//Задание размеров изображения согласно исходному
//Заменить widht - ширина, height - высота
BmpFile.SetBounds(0, 0, 164, 314);
//Подгоняем изображение под widht х height
BmpFile.Stretch:= true
//Привязка изображения к странице
BmpFile.Parent:= WizardForm.FinishedPage;
end;
end;


//конец








// Фриарк ------------------------------------------------------------------------------------------------------------------------------------------------
const
Archives = '*.arc'; // укажите расположение архивов FreeArc; для внешних файлов строку в [Files] добавлять необязательно

PM_REMOVE = 1;
CP_ACP = 0; CP_UTF8 = 65001;
oneMb = 1048576;

type
#ifdef UNICODE ; если у вас ошибка на этой строке, то установите препроцессор или исправьте скрипт для вашей версии Inno Setup
#define A "W"
#else
#define A "A" ; точка входа в SetWindowText, {#A} меняется на A или W в зависимости от версии
PAnsiChar = PChar; // Required for Inno Setup 5.3.0 and higher. (требуется для 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

TMyMsg = record
hwnd: HWND;
message: UINT;
wParam: Longint;
lParam: Longint;
time: DWORD;
pt: TPoint;
end;

TFreeArcCallback = function (what: PAnsiChar; int1, int2: Integer; str: PAnsiChar): Integer;
TArc = record Path: string; OrigSize: Integer; Size: Extended; end;

var
ExtractFile: TLabel;
lblExtractFileName: TLabel;
btnCancelUnpacking: TButton;
CancelCode, n, UnPackError, StartInstall: Integer;
Arcs: array of TArc;
msgError: string;
lastMb: Integer;
baseMb: Integer;
totalUncompressedSize: Integer; // total uncompressed size of archive data in mb
LastTimerEvent: DWORD;

Function MultiByteToWideChar(CodePage: UINT; dwFlags: DWORD; lpMultiByteStr: string; cbMultiByte: integer; lpWideCharStr: string; cchWideChar: integer): longint; external 'MultiByteToWideChar@kernel32.dll stdcall';
Function WideCharToMultiByte(CodePage: UINT; dwFlags: DWORD; lpWideCharStr: string; cchWideChar: integer; lpMultiByteStr: string; cbMultiByte: integer; lpDefaultChar: integer; lpUsedDefaultChar: integer): longint; external 'WideCharToMultiByte@kernel32.dll stdcall';

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

Function OemToChar(lpszSrc, lpszDst: AnsiString): longint; external 'OemToCharA@user32.dll stdcall';
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 GetTickCount: DWord; external 'GetTickCount@kernel32';
function WrapFreeArcCallback (callback: TFreeArcCallback; paramcount: integer):longword; external 'wrapcallback@files:innocallback.dll stdcall';
function FreeArcExtract (callback: longword; cmd1,cmd2,cmd3,cmd4,cmd5,cmd6,cmd7,cmd8,cmd9,cmd10: PAnsiChar): integer; external 'FreeArcExtract@files:unarc.dll cdecl';

procedure AppProcessMessage;
var
Msg: TMyMsg;
begin
while PeekMessage(Msg, 0, 0, 0, PM_REMOVE) do begin
TranslateMessage(Msg);
DispatchMessage(Msg);
end;
end;

// Перевод числа в строку с точностью 3 знака (%.3n) с округлением дробной части, если она есть
Function NumToStr(Float: Extended): String;
Begin
Result:= Format('%.3n', [Float]); StringChange(Result, ',', '.');
while ((Result[Length(Result)] = '0') or (Result[Length(Result)] = '.')) and (Length(Result) > 1) do
SetLength(Result, Length(Result)-1);
End;

function cm(Message: String): String; Begin Result:= ExpandConstant('{cm:'+ Message +'}') 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;

// 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 : integer;
WideCharBuf: string;
MultiByteBuf: string;
begin
strSource:= strSource + chr(0);
SetLength( WideCharBuf, Length( strSource ) * 2 );
SetLength( MultiByteBuf, Length( strSource ) * 2 );

nRet:= MultiByteToWideChar( CP_ACP, 0, strSource, -1, WideCharBuf, Length(WideCharBuf) );
nRet:= WideCharToMultiByte( CP_UTF8, 0, WideCharBuf, -1, MultiByteBuf, Length(MultiByteBuf), 0, 0);

Result:= MultiByteBuf;
end;

// OnClick event function for btnCancel
procedure btnCancelUnpackingOnClick(Sender: TObject);
begin
if MsgBox( SetupMessage( msgExitSetupMessage ), mbInformation, MB_YESNO ) = IDYES then
CancelCode:= -127;
end;

var origsize: Integer;
// The callback function for getting info about FreeArc archive
function FreeArcInfoCallback (what: PAnsiChar; Mb, sizeArc: Integer; str: PAnsiChar): Integer;
begin
if string(what)='origsize' then origsize := Mb else
if string(what)='compsize' then else
if string(what)='total_files' then else
Result:= CancelCode;
end;

// Returns decompressed size of files in archive
function ArchiveOrigSize(arcname: string): Integer;
var
callback: longword;
Begin
callback:= WrapFreeArcCallback(@FreeArcInfoCallback,4); //FreeArcInfoCallback has 4 arguments
CancelCode:= 0;
AppProcessMessage;
try
// Pass the specified arguments to 'unarc.dll'
Result:= FreeArcExtract (callback, 'l', '--', AnsiToUtf8(arcname), '', '', '', '', '', '', '');
if CancelCode < 0 then Result:= CancelCode;
if Result >= 0 then Result:= origsize;
except
Result:= -63; // ArcFail
end;
end;

// Scans the specified folders for archives and add them to list
function FindArcs(dir: string): Extended;
var
FSR: TFindRec;
Begin
Result:= 0;
if FindFirst(ExpandConstant(dir), FSR) then begin
try
repeat
// Skip everything but the folders
if FSR.Attributes and FILE_ATTRIBUTE_DIRECTORY > 0 then CONTINUE;
n:= GetArrayLength(Arcs);
// Expand the folder list
SetArrayLength(Arcs, n +1);
Arcs[n].Path:= ExtractFilePath(ExpandConstant(dir)) + FSR.Name;
Arcs[n].Size:= Size64(FSR.SizeHigh, FSR.SizeLow);
Result:= Result + Arcs[n].Size;
Arcs[n].OrigSize := ArchiveOrigSize(Arcs[n].Path)
totalUncompressedSize := totalUncompressedSize + Arcs[n].OrigSize
until not FindNext(FSR);
finally
FindClose(FSR);
end;
end;
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;

// Converts milliseconds to human-readable time
// Конвертирует милисекунды в человеко-читаемое изображение времени
Function TicksToTime(Ticks: DWord; h,m,s: String; detail: Boolean): String;
Begin
if detail {hh:mm:ss format} then
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 {more than hour} then
Result:= IntToStr(Ticks/3600000) +h+' '+ PADZ(IntToStr((Ticks/1000 - Ticks/1000/3600*3600)/60), 2) +m
else if Ticks/60 >= 1000 {1..60 minutes} then
Result:= IntToStr(Ticks/60000) +m+' '+ PADZ(IntToStr(Ticks/1000 - Ticks/1000/60*60), 2) +s
else Result:= IntToStr(Ticks/1000) +s {less than one minute}
End;

// The main callback function for unpacking FreeArc archives
function FreeArcCallback (what: PAnsiChar; Mb, sizeArc: Integer; str: PAnsiChar): Integer;
var
percents, Remaining: Integer;
s: String;
begin
if GetTickCount - LastTimerEvent > 1000 then begin
// This code will be executed once each 1000 ms (этот код будет выполняться раз в 1000 миллисекунд)
// ....
// End of code executed by timer
LastTimerEvent := LastTimerEvent+1000;
end;

if string(what)='filename' then begin
// Update FileName label
lblExtractFileName.Caption:= FmtMessage( cm( 'Extracting' ), [OemToAnsiStr( str )] )
end else if (string(what)='write') and (totalUncompressedSize>0) and (Mb>lastMb) then begin
// Assign to Mb *total* amount of data extracted to the moment from all archives
lastMb := Mb;
Mb := baseMb+Mb;

// Update progress bar
WizardForm.ProgressGauge.Position:= Mb;

// Show how much megabytes/archives were processed up to the moment
percents:= (Mb*1000) div totalUncompressedSize;
s := FmtMessage(cm('ExtractedInfo'), [IntToStr(Mb), IntToStr(totalUncompressedSize)]);
if GetArrayLength(Arcs)>1 then
s := s + '. '+FmtMessage(cm('ArcInfo'), [IntToStr(n+1), IntToStr(GetArrayLength(Arcs))])
ExtractFile.Caption := s

// Calculate and show current percents
percents:= (Mb*1000) div totalUncompressedSize;
s:= FmtMessage(cm('AllProgress'), [Format('%.1n', [Abs(percents/10)])]);
if Mb > 0 then Remaining:= trunc((GetTickCount - StartInstall) * Abs((totalUncompressedSize - Mb)/Mb)) else Remaining:= 0;
if Remaining = 0 then SetTaskBarTitle(cm('ending')) else begin
s:= s + '. '+FmtMessage(cm('remains'), [TicksToTime(Remaining, cm('hour'), cm('min'), cm('sec'), false)])
SetTaskBarTitle(FmtMessage(cm('taskbar'), [IntToStr(percents/10), TicksToTime(Remaining, 'h', 'm', 's', false)]))
end;
WizardForm.FileNameLabel.Caption := s
end;
AppProcessMessage;
Result:= CancelCode;
end;

// Extracts all found archives
function UnPack(Archives: string): Integer;
var
totalCompressedSize: Extended;
callback: longword;
FreeMB, TotalMB: Cardinal;
begin
// Display 'Extracting FreeArc archive'
lblExtractFileName.Caption:= '';
lblExtractFileName.Show;
ExtractFile.caption:= cm('ArcTitle');
ExtractFile.Show;
// Show the 'Cancel unpacking' button and set it as default button
btnCancelUnpacking.Caption:= WizardForm.CancelButton.Caption;
btnCancelUnpacking.Show;
WizardForm.ActiveControl:= btnCancelUnpacking;
WizardForm.ProgressGauge.Position:= 0;
// Get the size of all archives
totalUncompressedSize := 0;
totalCompressedSize := FindArcs(Archives);
WizardForm.ProgressGauge.Max:= totalUncompressedSize;
// Other initializations
callback:= WrapFreeArcCallback(@FreeArcCallback,4); //FreeArcCallback has 4 arguments
StartInstall:= GetTickCount; {время начала распаковки}
LastTimerEvent:= GetTickCount;
baseMb:= 0

for n:= 0 to GetArrayLength(Arcs) -1 do
begin
lastMb := 0
CancelCode:= 0;
AppProcessMessage;
try
// Pass the specified arguments to 'unarc.dll'
Result:= FreeArcExtract (callback, 'x', '-o+', '-dp' + AnsiToUtf8( ExpandConstant('{app}') ), '--', AnsiToUtf8(Arcs[n].Path), '', '', '', '', '');
if CancelCode < 0 then Result:= CancelCode;
except
Result:= -63; // ArcFail
end;
baseMb:= baseMb+lastMb

// Error occured
if Result <> 0 then
begin
msgError:= FmtMessage(cm('ArcError'), [IntToStr(Result)]);
GetSpaceOnDisk(ExtractFileDrive(ExpandConstant('{app}')), True, FreeMB, TotalMB);
case Result of
-1: if FreeMB < 32 {Мб на диске} then msgError:= SetupMessage(msgDiskSpaceWarningTitle)
else msgError:= msgError + #13#10 + FmtMessage(cm('ArcBroken'), [ExtractFileName(Arcs[n].Path)]);
-127: msgError:= cm('ArcBreak'); //Cancel button
-63: msgError:= cm('ArcFail');
end;
// MsgBox(msgError, mbInformation, MB_OK); //сообщение показывается на странице завершения
Log(msgError);
Break; //прервать цикл распаковки
end;
end;
// Hide labels and button
WizardForm.FileNameLabel.Caption:= '';
lblExtractFileName.Hide;
ExtractFile.Hide;
btnCancelUnpacking.Hide;
end;

procedure CurStepChanged1(CurStep: TSetupStep);
begin
if CurStep = ssPostInstall then
begin
UnPackError:= UnPack(Archives)
if UnPackError = 0 then
SetTaskBarTitle(SetupMessage(msgSetupAppTitle))
else
begin
// Error occured, uninstall it then
Exec(ExpandConstant('{uninstallexe}'), '/SILENT','', sw_Hide, ewWaitUntilTerminated, n); //откат установки из-за ошибки unarc.dll
SetTaskBarTitle(SetupMessage(msgErrorTitle))
WizardForm.Caption:= SetupMessage(msgErrorTitle) +' - '+ cm('ArcBreak')
end;
end;
end;

// стандартный способ отката (не нужна CurPageChanged), но архивы распаковываются до извлечения файлов инсталлятора
// if CurStep = ssInstall then
// if UnPack(Archives) <> 0 then Abort;

Procedure CurPageChanged1(CurPageID: Integer);
Begin
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 InitializeWizard3();
begin
with WizardForm.ProgressGauge do
begin
// Create a label to show current FileName being extracted
lblExtractFileName:= TLabel.Create(WizardForm);
lblExtractFileName.parent:=WizardForm.InstallingPage;
lblExtractFileName.autosize:=false;
lblExtractFileName.Width:= Width;
lblExtractFileName.top:=Top + ScaleY(35);
lblExtractFileName.Caption:= '';
lblExtractFileName.Hide;

// Create a label to show percentage
ExtractFile:= TLabel.Create(WizardForm);
ExtractFile.parent:=WizardForm.InstallingPage;
ExtractFile.autosize:=false;
ExtractFile.Width:= Width;
ExtractFile.top:=lblExtractFileName.Top + ScaleY(16);
ExtractFile.caption:= '';
ExtractFile.Hide;
end;

// Create a 'Cancel unpacking' button and hide it for now.
btnCancelUnpacking:=TButton.create(WizardForm);
btnCancelUnpacking.Parent:= WizardForm;
btnCancelUnpacking.SetBounds(WizardForm.CancelButton.Left, WizardForm.CancelButton.top, WizardForm.CancelButton.Width, WizardForm.CancelButton.Height);
btnCancelUnpacking.OnClick:= @btnCancelUnpackingOnClick;
btnCancelUnpacking.Hide;
end;


// Чек боксы и проверка харды ------------------------------------------------------------------------------------------------------------------------------------------------
const
NeedSize = 10000;

var
NeedSpaceLabel,FreeSpaceLabel: TLabel;
FreeMB, TotalMB: Cardinal;
Icons: TCheckBox;

function InstallDirectX: Boolean;
begin
end;

function InstallRedist: Boolean;
begin
end;
////////////////////////////////////////////////////////////////////////////////////////////////////////
function InstallPhysX: Boolean;
begin
end;

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

procedure RedistOnClick(Sender: TObject);
begin
end;

procedure DirectXLabelOnClick(Sender: TObject);
begin
end;

procedure IconsOnClick(Sender: TObject);
begin
if Icons.Checked = False then
Icons.Checked:= True else
Icons.Checked:= False;
end;
procedure GetFreeSpaceCaption(Sender: TObject);
var
Path: String;
begin
Path := ExtractFileDrive(WizardForm.DirEdit.Text);
GetSpaceOnDisk(Path, True, FreeMB, TotalMB);
if FreeMB > 1024 then
FreeSpaceLabel.Caption := 'Свободно на выбранном диске: ' + FloatToStr(round(FreeMB/1024*100)/100) + ' GB'
else
FreeSpaceLabel.Caption := 'Свободно на выбранном диске: ' + IntToStr(FreeMB)+ ' MB';
begin
if FreeMB < NeedSize then
begin
WizardForm.NextButton.Enabled:=false;
end else
WizardForm.NextButton.Enabled:=true;
end;
end;

procedure InitializeWizard5();
begin
WizardForm.DiskSpaceLabel.Hide;

NeedSpaceLabel := TLabel.Create(WizardForm);
with NeedSpaceLabel do
begin
Parent := WizardForm.SelectDirPage;
Left := ScaleX(0);
Top := ScaleY(198);
Width := ScaleX(209);
Height := ScaleY(13);
Caption := 'Требуется для установки: 12 GB';
end;

FreeSpaceLabel := TLabel.Create(WizardForm);
with FreeSpaceLabel do
begin
Parent := WizardForm.SelectDirPage;
Left := ScaleX(0);
Top := ScaleY(216);
Width := ScaleX(209);
Height := ScaleY(13);
end;

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

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

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


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

STRELOK
27-11-2009, 09:50
Вот с этим

var
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 InitializeWizard();
begin
NeedSize := 6100; //Здесь указывается место для приложения
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 CurPageChanged(CurPageID: Integer);
begin
if CurPageID=wpSelectDir then
begin
GetNeedSpaceCaption;
if FreeMB < NeedSize then
WizardForm.NextButton.Enabled:=False
ListBoxRefresh
end;
end;

написал в 2 сообщ т.к в 1 не помещается

volk1234
27-11-2009, 11:33
STRELOK

1. Используйте тег [code]
2. Большие скрипты лучше выкладывайть в виде вложенных файлов.

Raf-9600
27-11-2009, 11:35
Raf-9600, соединил, только "Запрет установки в папку Windows" здесь отсутствует (там ошибка в самом коде есть; MessageBox изменил на MsgBox и появилась другая ошибка )

Скрипт проверял на IS от Restools...
З.Ы. Если где-то будут крякозяблины - твоя вина; возможно когда копировал скрипты (Слайд-шоу и Деинсталлятора), был включен английский язык, просто найдёшь и заменишь на строки из исходника »
Спасибо! Я уш не думал что кто-то возьмется.

Правда есть два нюанса:
1. В классической версии Inno, не отображается список винтов.
2. Если использовать "BeveledLabel", то страница с слайд-шоу выглядит не очень эстетично.

http://pic.ipicture.ru/uploads/091127/31077/thumbs/PBjsjNjBmd.png (http://ipicture.ru/Gallery/Viewfull/27652856.html)

Можно сделать чтоб BeveledLabel не отображался на этой странице?

STRELOK
27-11-2009, 11:41
volk1234,
пробывал, делал, за тем выскакивала ошибка на строке [code] я её удалял, за тем оно просило все удалить( до бесконечности.) а без него выскакивает ошибка связанная либо с var, либо с n: Integer; и с procedure InitializeWizard();

volk1234
27-11-2009, 13:11
Вы меня не поняли. :)
Я про ваши посты - сообщения здесь.
Закрывайте код скрипта в тег так будет всем удобнее.
Пример:

[code]
x=u
y=a
z=1

В компилятор не надо вставлять...

STRELOK
27-11-2009, 13:27
ок.
возник другой вопрос
как исправить вот это?
http://pic.ipicture.ru/uploads/091127/thumbs/75h2UCzVjj.jpg (http://ipicture.ru/Gallery/Viewfull/27659941.html)
Вот скрипт


[Setup]
AppName=Call of Duty Modern Warfare 2
AppVerName=Call of Duty Modern Warfare 2
DefaultDirName={pf}\Call of Duty Modern Warfare 2
DefaultGroupName=Call of Duty Modern Warfare 2
UsePreviousAppDir=false
DirExistsWarning=no
ShowLanguageDialog=yes
OutputBaseFilename=setup
OutputDir=/сod6
VersionInfoCopyright=kid#why? ^_-
WizardImageFile=WizardImage1231.bmp
WizardSmallImageFile=small11.bmp
AppCopyRight=kid#why? ^_-
Compression=lzma/ultra64
InternalCompressLevel=ultra64
SolidCompression=true
DiskSpanning=yes
DiskSliceSize=1000000000
SlicesPerDisk=2
SetupIconFile=Icon.ico

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

[CustomMessages]
eng.ArcBreak=Installation cancelled!
eng.ExtractedInfo=Extracted %1 Mb of %2 Mb
eng.ArcInfo=Archive: %1 of %2
eng.ArcTitle=Extracting FreeArc archive
eng.ArcError=Decompression failed with error code %1
eng.ArcFail=Decompression failed!
eng.AllProgress=Overall extraction progress: %1%%
eng.ArcBroken=Archive %1 is damaged%nor not enough free space.
eng.Extracting=Extracting: %1
eng.taskbar=%1%%, %2 remains
eng.remains=Remaining time: %1
eng.LongTime=at no time
eng.ending=ending
eng.hour= hours
eng.min= mins
eng.sec= secs

rus.ArcBreak=Установка прервана!
rus.ExtractedInfo=Распаковано %1 Мб из %2 Мб
rus.ArcInfo=Архив: %1 из %2
rus.ArcTitle=Распаковка архивов FreeArc
rus.ArcError=Распаковщик FreeArc вернул код ошибки: %1
rus.ArcFail=Распаковка не завершена!
rus.AllProgress=Общий прогресс распаковки: %1%%
rus.ArcBroken=Возможно, архив %1 повреждён%nили недостаточно места на диске назначения.
rus.Extracting=Распаковывается: %1
rus.taskbar=%1%%, жди %2
rus.remains=Осталось ждать %1
rus.LongTime=вечно
rus.ending=завершение
rus.hour= часов
rus.min= мин
rus.sec= сек

[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"
Name: task1; Description: Доп. программное обеспечение
Name: task1\task2; Description: DirectX
Name: task1\task3; Description: Visual C++

[Icons]
Name: "{group}\Call of Duty Modern Warfare 2"; Filename: "{app}\iw4sp.exe"; WorkingDir: "{app}"; Parameters: Call of Duty Modern Warfare 2;
Name: "{userdesktop}\Call of Duty Modern Warfare 2"; Filename: "{app}\iw4sp.exe"; WorkingDir: "{app}"; Tasks: desktopicon; Parameters: Call of Duty Modern Warfare 2;
Name: "{group}\{cm:UninstallProgram,Call of Duty Modern Warfare 2}"; Filename: "{uninstallexe}"

[Run]
Filename: {src}\DirectX\dxsetup.exe; Parameters: /silent; StatusMsg: Идет установка дополнительных программ...; Tasks: task1\task2; Flags: waituntilterminated
Filename: {src}\Redist\vcredist_x86.exe; Parameters: /Q; StatusMsg: Идет установка дополнительных программ...; Tasks: task1\task3; Flags: waituntilterminated

[Files]
;Source: *.arc; DestDir: {app}; Flags: nocompression deleteafterinstall
Source: unarc.dll; DestDir: {tmp}; Flags: dontcopy deleteafterinstall
Source: compiler:InnoCallback.dll; DestDir: {tmp}; Flags: dontcopy
Source: logo1.bmp; DestDir: {tmp}; Flags: dontcopy


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


// Страница приветствия ---------------------------------------------------------------------------------------------------------------------------------

procedure InitializeWizard2();
var
WLabel1, WLabel2: TLabel;
//FLabel1, FLabel2: TLabel;
bottom_img:TBitmapImage;
BmpFile: TBitmapImage;
FinishedHeadingLabel ,FinishedLabel:TLabel;

begin
WizardForm.WelcomeLabel1.Hide;
WizardForm.WelcomeLabel2.Hide;
WizardForm.WizardBitmapImage.Width := 497;
WizardForm.WizardBitmapImage.Height := 314;
WizardForm.Bevel1.Hide;
WizardForm.FinishedHeadingLabel.Hide;
WizardForm.FinishedLabel.Hide;
begin

ExtractTemporaryFile('logo1.bmp');
bottom_img:= TBitmapImage.Create(WizardForm);
bottom_img.Bitmap.LoadFromFile(ExpandConstant('{tmp}\logo1.bmp'));
bottom_img.SetBounds(5, 320, 128, 30); {первые 2 параметра - координаты левогого верхнего угла по горизонтали и вертикали, дальше ширина и высота, до которой растянуть}
bottom_img.Parent:= WizardForm;
bottom_img.Stretch:= True;
end;

WizardForm.Caption:='Программа установки игры "Call of Duty: Modern Warfare 2"';
WizardForm.WelcomeLabel1.Hide;
WizardForm.WelcomeLabel2.Hide;
WizardForm.FinishedHeadingLabel.Hide;
WizardForm.FinishedLabel.Hide;
WizardForm.WizardBitmapImage.Width := 497;
WizardForm.WizardBitmapImage.Height := 313;
WizardForm.WizardSmallBitmapImage.Left:=0;
WizardForm.WizardSmallBitmapImage.Width:=497;
WizardForm.WizardSmallBitmapImage.Height:=58;
WizardForm.PageDescriptionLabel.Width:=300;
WizardForm.PageNameLabel.Width:=300;
WizardForm.FileNameLabel.Visible:=False;
WizardForm.ProgressGauge.Top:=ScaleY(100);
WizardForm.StatusLabel.Top:=ScaleY(80);
WLabel1 := TLabel.Create(WizardForm);
WLabel1.Left := ScaleX(176);
WLabel1.Top := ScaleY(16);
WLabel1.Width := ScaleX(301);
WLabel1.Height := ScaleY(54);
WLabel1.AutoSize := False;
WLabel1.WordWrap := True;
WLabel1.Font.Size := 11;
WLabel1.Font.Style := [fsBold];
WLabel1.Font.Color:= clBlack;
WLabel1.WordWrap := True;
WLabel1.Font.Color:= clBlack;

WLabel1.Caption := WizardForm.WelcomeLabel1.Caption;
WLabel1.Transparent := True;
WLabel1.Parent := WizardForm.WelcomePage;
WLabel2 :=TLabel.Create(WizardForm);
WLabel2.Top := ScaleY(20);
WLabel2.Left := ScaleX(180);
WLabel2.Width := ScaleX(300);
WLabel2.Height := ScaleY(234);
WLabel2.AutoSize := False;
WLabel2.WordWrap := True;
WLabel2.AutoSize := False;
WLabel2.WordWrap := True;
WLabel2.Font.Size := 9;
WLabel2.Font.Style := [fsBold];
WLabel2.Font.Color:= clGreen;
WLabel2.Font.name:='Constantia';
WLabel2.ShowAccelChar := False;
WLabel2.Caption := WizardForm.WelcomeLabel1.Caption;
WLabel2.Transparent := True;
WLabel2.Parent := WizardForm.WelcomePage;


WLabel2.Caption := WizardForm.WelcomeLabel2.Caption;
WLabel2.Transparent := True;
WLabel2.Parent := WizardForm.WelcomePage;
WizardForm.WizardBitmapImage2.Width := 497;
WizardForm.WizardBitmapImage2.Height := 313;
WLabel2 := TLabel.Create(WizardForm);
WLabel1.Left := ScaleX(176);
WLabel1.Top := ScaleY(16);
WLabel1.Width := ScaleX(301);
WLabel1.Height := ScaleY(54);
WLabel1.AutoSize := False;
WLabel1.WordWrap := True;
WLabel1.Font.Size := 11;
WLabel1.Font.Style := [fsBold];
WLabel1.Font.Color:= clGreen;

WLabel1.Caption := WizardForm.FinishedHeadingLabel.Caption;
WLabel1.Transparent := True;
WLabel1.Parent := WizardForm.FinishedPage;
WLabel2 :=TLabel.Create(WizardForm);
WLabel2.Top := ScaleY(60);
WLabel2.Left := ScaleX(180);
WLabel2.Width := ScaleX(300);
WLabel2.Height := ScaleY(234);
WLabel2.AutoSize := False;
WLabel2.WordWrap := True;
WLabel2.AutoSize := False;
WLabel2.WordWrap := True;
WLabel2.Font.Size := 10;
WLabel2.Font.Style := [fsBold];
WLabel2.Font.Color:= clGreen;
WLabel2.Font.name:='Constantia';
WLabel2.ShowAccelChar := False;
WLabel2.Caption := WizardForm.WelcomeLabel1.Caption;
WLabel2.Transparent := True;
WLabel2.Parent := WizardForm.WelcomePage;

WLabel2.Caption := 'Программа установлена на Ваш компьютер.' #13#13
'Нажмите «Завершить», чтобы выйти из программы установки.';
WLabel2.Transparent := True;
WLabel2.Parent := WizardForm.FinishedPage;



//////////////////Картинка вверху//////////////////////////
begin
with WizardForm do begin
with MainPanel do
Height := Height - 0;
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;


begin
//Извлечение изображения
//Динамическое выделение памяти под изображение (BMP-файла)
BmpFile:= TBitmapImage.Create(WizardForm);
//Загрузка изображения из директории, в которую извлекали файл
//Задание размеров изображения согласно исходному
//Заменить widht - ширина, height - высота
BmpFile.SetBounds(0, 0, 164, 314);
//Подгоняем изображение под widht х height
BmpFile.Stretch:= true
//Привязка изображения к странице
BmpFile.Parent:= WizardForm.FinishedPage;
end;
end;


//конец








// Фриарк ------------------------------------------------------------------------------------------------------------------------------------------------
const
Archives = '*.arc'; // укажите расположение архивов FreeArc; для внешних файлов строку в [Files] добавлять необязательно

PM_REMOVE = 1;
CP_ACP = 0; CP_UTF8 = 65001;
oneMb = 1048576;

type
#ifdef UNICODE ; если у вас ошибка на этой строке, то установите препроцессор или исправьте скрипт для вашей версии Inno Setup
#define A "W"
#else
#define A "A" ; точка входа в SetWindowText, {#A} меняется на A или W в зависимости от версии
PAnsiChar = PChar; // Required for Inno Setup 5.3.0 and higher. (требуется для 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

TMyMsg = record
hwnd: HWND;
message: UINT;
wParam: Longint;
lParam: Longint;
time: DWORD;
pt: TPoint;
end;

TFreeArcCallback = function (what: PAnsiChar; int1, int2: Integer; str: PAnsiChar): Integer;
TArc = record Path: string; OrigSize: Integer; Size: Extended; end;

var
ExtractFile: TLabel;
lblExtractFileName: TLabel;
btnCancelUnpacking: TButton;
CancelCode, n, UnPackError, StartInstall: Integer;
Arcs: array of TArc;
msgError: string;
lastMb: Integer;
baseMb: Integer;
totalUncompressedSize: Integer; // total uncompressed size of archive data in mb
LastTimerEvent: DWORD;

Function MultiByteToWideChar(CodePage: UINT; dwFlags: DWORD; lpMultiByteStr: string; cbMultiByte: integer; lpWideCharStr: string; cchWideChar: integer): longint; external 'MultiByteToWideChar@kernel32.dll stdcall';
Function WideCharToMultiByte(CodePage: UINT; dwFlags: DWORD; lpWideCharStr: string; cchWideChar: integer; lpMultiByteStr: string; cbMultiByte: integer; lpDefaultChar: integer; lpUsedDefaultChar: integer): longint; external 'WideCharToMultiByte@kernel32.dll stdcall';

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

Function OemToChar(lpszSrc, lpszDst: AnsiString): longint; external 'OemToCharA@user32.dll stdcall';
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 GetTickCount: DWord; external 'GetTickCount@kernel32';
function WrapFreeArcCallback (callback: TFreeArcCallback; paramcount: integer):longword; external 'wrapcallback@files:innocallback.dll stdcall';
function FreeArcExtract (callback: longword; cmd1,cmd2,cmd3,cmd4,cmd5,cmd6,cmd7,cmd8,cmd9,cmd10: PAnsiChar): integer; external 'FreeArcExtract@files:unarc.dll cdecl';

procedure AppProcessMessage;
var
Msg: TMyMsg;
begin
while PeekMessage(Msg, 0, 0, 0, PM_REMOVE) do begin
TranslateMessage(Msg);
DispatchMessage(Msg);
end;
end;

// Перевод числа в строку с точностью 3 знака (%.3n) с округлением дробной части, если она есть
Function NumToStr(Float: Extended): String;
Begin
Result:= Format('%.3n', [Float]); StringChange(Result, ',', '.');
while ((Result[Length(Result)] = '0') or (Result[Length(Result)] = '.')) and (Length(Result) > 1) do
SetLength(Result, Length(Result)-1);
End;

function cm(Message: String): String; Begin Result:= ExpandConstant('{cm:'+ Message +'}') 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;

// 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 : integer;
WideCharBuf: string;
MultiByteBuf: string;
begin
strSource:= strSource + chr(0);
SetLength( WideCharBuf, Length( strSource ) * 2 );
SetLength( MultiByteBuf, Length( strSource ) * 2 );

nRet:= MultiByteToWideChar( CP_ACP, 0, strSource, -1, WideCharBuf, Length(WideCharBuf) );
nRet:= WideCharToMultiByte( CP_UTF8, 0, WideCharBuf, -1, MultiByteBuf, Length(MultiByteBuf), 0, 0);

Result:= MultiByteBuf;
end;

// OnClick event function for btnCancel
procedure btnCancelUnpackingOnClick(Sender: TObject);
begin
if MsgBox( SetupMessage( msgExitSetupMessage ), mbInformation, MB_YESNO ) = IDYES then
CancelCode:= -127;
end;

var origsize: Integer;
// The callback function for getting info about FreeArc archive
function FreeArcInfoCallback (what: PAnsiChar; Mb, sizeArc: Integer; str: PAnsiChar): Integer;
begin
if string(what)='origsize' then origsize := Mb else
if string(what)='compsize' then else
if string(what)='total_files' then else
Result:= CancelCode;
end;

// Returns decompressed size of files in archive
function ArchiveOrigSize(arcname: string): Integer;
var
callback: longword;
Begin
callback:= WrapFreeArcCallback(@FreeArcInfoCallback,4); //FreeArcInfoCallback has 4 arguments
CancelCode:= 0;
AppProcessMessage;
try
// Pass the specified arguments to 'unarc.dll'
Result:= FreeArcExtract (callback, 'l', '--', AnsiToUtf8(arcname), '', '', '', '', '', '', '');
if CancelCode < 0 then Result:= CancelCode;
if Result >= 0 then Result:= origsize;
except
Result:= -63; // ArcFail
end;
end;

// Scans the specified folders for archives and add them to list
function FindArcs(dir: string): Extended;
var
FSR: TFindRec;
Begin
Result:= 0;
if FindFirst(ExpandConstant(dir), FSR) then begin
try
repeat
// Skip everything but the folders
if FSR.Attributes and FILE_ATTRIBUTE_DIRECTORY > 0 then CONTINUE;
n:= GetArrayLength(Arcs);
// Expand the folder list
SetArrayLength(Arcs, n +1);
Arcs[n].Path:= ExtractFilePath(ExpandConstant(dir)) + FSR.Name;
Arcs[n].Size:= Size64(FSR.SizeHigh, FSR.SizeLow);
Result:= Result + Arcs[n].Size;
Arcs[n].OrigSize := ArchiveOrigSize(Arcs[n].Path)
totalUncompressedSize := totalUncompressedSize + Arcs[n].OrigSize
until not FindNext(FSR);
finally
FindClose(FSR);
end;
end;
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;

// Converts milliseconds to human-readable time
// Конвертирует милисекунды в человеко-читаемое изображение времени
Function TicksToTime(Ticks: DWord; h,m,s: String; detail: Boolean): String;
Begin
if detail {hh:mm:ss format} then
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 {more than hour} then
Result:= IntToStr(Ticks/3600000) +h+' '+ PADZ(IntToStr((Ticks/1000 - Ticks/1000/3600*3600)/60), 2) +m
else if Ticks/60 >= 1000 {1..60 minutes} then
Result:= IntToStr(Ticks/60000) +m+' '+ PADZ(IntToStr(Ticks/1000 - Ticks/1000/60*60), 2) +s
else Result:= IntToStr(Ticks/1000) +s {less than one minute}
End;

// The main callback function for unpacking FreeArc archives
function FreeArcCallback (what: PAnsiChar; Mb, sizeArc: Integer; str: PAnsiChar): Integer;
var
percents, Remaining: Integer;
s: String;
begin
if GetTickCount - LastTimerEvent > 1000 then begin
// This code will be executed once each 1000 ms (этот код будет выполняться раз в 1000 миллисекунд)
// ....
// End of code executed by timer
LastTimerEvent := LastTimerEvent+1000;
end;

if string(what)='filename' then begin
// Update FileName label
lblExtractFileName.Caption:= FmtMessage( cm( 'Extracting' ), [OemToAnsiStr( str )] )
end else if (string(what)='write') and (totalUncompressedSize>0) and (Mb>lastMb) then begin
// Assign to Mb *total* amount of data extracted to the moment from all archives
lastMb := Mb;
Mb := baseMb+Mb;

// Update progress bar
WizardForm.ProgressGauge.Position:= Mb;

// Show how much megabytes/archives were processed up to the moment
percents:= (Mb*1000) div totalUncompressedSize;
s := FmtMessage(cm('ExtractedInfo'), [IntToStr(Mb), IntToStr(totalUncompressedSize)]);
if GetArrayLength(Arcs)>1 then
s := s + '. '+FmtMessage(cm('ArcInfo'), [IntToStr(n+1), IntToStr(GetArrayLength(Arcs))])
ExtractFile.Caption := s

// Calculate and show current percents
percents:= (Mb*1000) div totalUncompressedSize;
s:= FmtMessage(cm('AllProgress'), [Format('%.1n', [Abs(percents/10)])]);
if Mb > 0 then Remaining:= trunc((GetTickCount - StartInstall) * Abs((totalUncompressedSize - Mb)/Mb)) else Remaining:= 0;
if Remaining = 0 then SetTaskBarTitle(cm('ending')) else begin
s:= s + '. '+FmtMessage(cm('remains'), [TicksToTime(Remaining, cm('hour'), cm('min'), cm('sec'), false)])
SetTaskBarTitle(FmtMessage(cm('taskbar'), [IntToStr(percents/10), TicksToTime(Remaining, 'h', 'm', 's', false)]))
end;
WizardForm.FileNameLabel.Caption := s
end;
AppProcessMessage;
Result:= CancelCode;
end;

// Extracts all found archives
function UnPack(Archives: string): Integer;
var
totalCompressedSize: Extended;
callback: longword;
FreeMB, TotalMB: Cardinal;
begin
// Display 'Extracting FreeArc archive'
lblExtractFileName.Caption:= '';
lblExtractFileName.Show;
ExtractFile.caption:= cm('ArcTitle');
ExtractFile.Show;
// Show the 'Cancel unpacking' button and set it as default button
btnCancelUnpacking.Caption:= WizardForm.CancelButton.Caption;
btnCancelUnpacking.Show;
WizardForm.ActiveControl:= btnCancelUnpacking;
WizardForm.ProgressGauge.Position:= 0;
// Get the size of all archives
totalUncompressedSize := 0;
totalCompressedSize := FindArcs(Archives);
WizardForm.ProgressGauge.Max:= totalUncompressedSize;
// Other initializations
callback:= WrapFreeArcCallback(@FreeArcCallback,4); //FreeArcCallback has 4 arguments
StartInstall:= GetTickCount; {время начала распаковки}
LastTimerEvent:= GetTickCount;
baseMb:= 0

for n:= 0 to GetArrayLength(Arcs) -1 do
begin
lastMb := 0
CancelCode:= 0;
AppProcessMessage;
try
// Pass the specified arguments to 'unarc.dll'
Result:= FreeArcExtract (callback, 'x', '-o+', '-dp' + AnsiToUtf8( ExpandConstant('{app}') ), '--', AnsiToUtf8(Arcs[n].Path), '', '', '', '', '');
if CancelCode < 0 then Result:= CancelCode;
except
Result:= -63; // ArcFail
end;
baseMb:= baseMb+lastMb

// Error occured
if Result <> 0 then
begin
msgError:= FmtMessage(cm('ArcError'), [IntToStr(Result)]);
GetSpaceOnDisk(ExtractFileDrive(ExpandConstant('{app}')), True, FreeMB, TotalMB);
case Result of
-1: if FreeMB < 32 {Мб на диске} then msgError:= SetupMessage(msgDiskSpaceWarningTitle)
else msgError:= msgError + #13#10 + FmtMessage(cm('ArcBroken'), [ExtractFileName(Arcs[n].Path)]);
-127: msgError:= cm('ArcBreak'); //Cancel button
-63: msgError:= cm('ArcFail');
end;
// MsgBox(msgError, mbInformation, MB_OK); //сообщение показывается на странице завершения
Log(msgError);
Break; //прервать цикл распаковки
end;
end;
// Hide labels and button
WizardForm.FileNameLabel.Caption:= '';
lblExtractFileName.Hide;
ExtractFile.Hide;
btnCancelUnpacking.Hide;
end;

procedure CurStepChanged1(CurStep: TSetupStep);
begin
if CurStep = ssPostInstall then
begin
UnPackError:= UnPack(Archives)
if UnPackError = 0 then
SetTaskBarTitle(SetupMessage(msgSetupAppTitle))
else
begin
// Error occured, uninstall it then
Exec(ExpandConstant('{uninstallexe}'), '/SILENT','', sw_Hide, ewWaitUntilTerminated, n); //откат установки из-за ошибки unarc.dll
SetTaskBarTitle(SetupMessage(msgErrorTitle))
WizardForm.Caption:= SetupMessage(msgErrorTitle) +' - '+ cm('ArcBreak')
end;
end;
end;

// стандартный способ отката (не нужна CurPageChanged), но архивы распаковываются до извлечения файлов инсталлятора
// if CurStep = ssInstall then
// if UnPack(Archives) <> 0 then Abort;

Procedure CurPageChanged1(CurPageID: Integer);
Begin
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 InitializeWizard3();
begin
with WizardForm.ProgressGauge do
begin
// Create a label to show current FileName being extracted
lblExtractFileName:= TLabel.Create(WizardForm);
lblExtractFileName.parent:=WizardForm.InstallingPage;
lblExtractFileName.autosize:=false;
lblExtractFileName.Width:= Width;
lblExtractFileName.top:=Top + ScaleY(35);
lblExtractFileName.Caption:= '';
lblExtractFileName.Hide;

// Create a label to show percentage
ExtractFile:= TLabel.Create(WizardForm);
ExtractFile.parent:=WizardForm.InstallingPage;
ExtractFile.autosize:=false;
ExtractFile.Width:= Width;
ExtractFile.top:=lblExtractFileName.Top + ScaleY(16);
ExtractFile.caption:= '';
ExtractFile.Hide;
end;

// Create a 'Cancel unpacking' button and hide it for now.
btnCancelUnpacking:=TButton.create(WizardForm);
btnCancelUnpacking.Parent:= WizardForm;
btnCancelUnpacking.SetBounds(WizardForm.CancelButton.Left, WizardForm.CancelButton.top, WizardForm.CancelButton.Width, WizardForm.CancelButton.Height);
btnCancelUnpacking.OnClick:= @btnCancelUnpackingOnClick;
btnCancelUnpacking.Hide;
end;


// Чек боксы и проверка харды ------------------------------------------------------------------------------------------------------------------------------------------------
const
NeedSize = 10000;

var
NeedSpaceLabel,FreeSpaceLabel: TLabel;
FreeMB, TotalMB: Cardinal;
Icons: TCheckBox;

function InstallDirectX: Boolean;
begin
end;

function InstallRedist: Boolean;
begin
end;
////////////////////////////////////////////////////////////////////////////////////////////////////////
function InstallPhysX: Boolean;
begin
end;

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

procedure RedistOnClick(Sender: TObject);
begin
end;

procedure DirectXLabelOnClick(Sender: TObject);
begin
end;

procedure IconsOnClick(Sender: TObject);
begin
if Icons.Checked = False then
Icons.Checked:= True else
Icons.Checked:= False;
end;
procedure GetFreeSpaceCaption(Sender: TObject);
var
Path: String;
begin
Path := ExtractFileDrive(WizardForm.DirEdit.Text);
GetSpaceOnDisk(Path, True, FreeMB, TotalMB);
if FreeMB > 1024 then
FreeSpaceLabel.Caption := 'Свободно на выбранном диске: ' + FloatToStr(round(FreeMB/1024*100)/100) + ' GB'
else
FreeSpaceLabel.Caption := 'Свободно на выбранном диске: ' + IntToStr(FreeMB)+ ' MB';
begin
if FreeMB < NeedSize then
begin
WizardForm.NextButton.Enabled:=false;
end else
WizardForm.NextButton.Enabled:=true;
end;
end;

procedure InitializeWizard5();
begin
WizardForm.DiskSpaceLabel.Hide;

NeedSpaceLabel := TLabel.Create(WizardForm);
with NeedSpaceLabel do
begin
Parent := WizardForm.SelectDirPage;
Left := ScaleX(0);
Top := ScaleY(198);
Width := ScaleX(209);
Height := ScaleY(13);
Caption := 'Требуется для установки: 12 GB';
end;

FreeSpaceLabel := TLabel.Create(WizardForm);
with FreeSpaceLabel do
begin
Parent := WizardForm.SelectDirPage;
Left := ScaleX(0);
Top := ScaleY(216);
Width := ScaleX(209);
Height := ScaleY(13);
end;

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

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

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


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

volk1234
27-11-2009, 13:45
Пользуйтесь расширеным режимом для написания сообщений
и очень советую почитать вот это:
http://forum.oszone.net/misc.php?do=bbcode

STRELOK
27-11-2009, 14:02
volk1234,
я вроде как ты сказал скрипт в [code] сделал. Что неправельно?

A1EXXX
27-11-2009, 14:10
Raf-9600, скрыть сам BeveledLabel не получилось, поэтому сделал немного иначе ;) (старый BeveledLabel просто удалишь из [Messages]): [Code]
Var
Text: TNewStaticText;

Procedure InitializeWizard();
begin
Text:=TNewStaticText.Create(WizardForm)
Text.Left:=10 // сдвиг влево
Text.Top:=305 // сдвиг вниз
Text.Color:=WizardForm.Color;
Text.Font.Name:='Courier New' // шрифт
Text.Font.Color:=clGray // цвет шрифта
Text.Caption:='Created by Raf-9600' // надпись
Text.Parent:=WizardForm
end;

procedure CurPageChanged(CurPageID: Integer);
begin
if (CurPageID = wpWelcome) or (CurPageID = wpFinished) or (CurPageID = wpInstalling) then // скроем надпись на стриницах Приветствия, Завершения (картинку портит) и Установки :)
begin
Text.Visible:= False;
end;

if (CurPageID = wpLicense) or (CurPageID = wpInfoBefore) or (CurPageID = wpSelectDir) then // начиная с любой из этих страниц надпись появится
begin
Text.Visible:= True;
end;
end;
По-моему, так даже лучше смотрится, вот скрин (http://s46.radikal.ru/i114/0911/58/0558e22d276a.jpg) :)

И добавил этот кусок в общий скрипт: [Code]
const
n=21; //количество слайдов
type
TProc = procedure(HandleW, msg, idEvent, TimeSys: LongWord);
TRandNumbers = array[1..N] 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;
bmp: TRandNumbers;
z:byte;

procedure OnTimer(HandleW, msg, idEvent, TimeSys: LongWord);
begin
currTime := currTime + 1;
if (currTime mod {#20} = 0) // здесь, вместо TIME_FOR_VIEW ввести время показа слайда (в секундах)
then begin
SplashImage.Bitmap.LoadFromFile(ExpandConstant('{tmp}\Image_'+inttostr(bmp[currTime/{#20}])+'.bmp')); // здесь тоже
if (currTime/{#20} = N) then currTime:=0 ; // и здесь
end;
end;


procedure InitializeWizard1;
begin
bmp:=get_unique_random_number(N);
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 N do ExtractTemporaryFile('Image_'+inttostr(bmp[z])+'.bmp');
end;
end;

procedure CurPageChanged1(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 DeInitializeSetup1();
begin
KillTimer(0, TimerID);
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 InitializeWizard2();
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;


//I?iaa?ea ia inoaaouany oaeeu
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('Iaiea "' + ExpandConstant('{app}') + '" ia ii?i?iy.'#13#13 +
'"Oae" – iiaia aeaaeaiiy an?o oaee?a o iaio?, aee??a??e naio iaieo.' #13#13 +
'"I?" – a?ae?eoe iaieo a i?ia?aieeo, uia a?o?io aeaaeeoe oaeee.'#13#13 +
'"Neanoaaoe" – i??iai ia ?iaeoe, aeaaeeoe iaieo i?ci?oa naiino?eii.', mbInformation, MB_YESNOCANCEL) of

IDYES:
if not DelTree(ExpandConstant('{app}'), True, True, True) then
MsgBox('Iaiea ia aeaaeaia.' #13#13 'Iaiea aai iaei c oaee?a o i?e caa?yi? ?ioi? i?ia?aii?.', mbError, MB_OK);

IDNO:
if not ShellExec('open', ExpandConstant('{app}'), '', '', SW_SHOWMAXIMIZED, ewNoWait, Res) then
MsgBox('Iiieeea a?ae?eooy.' #13#13 'Iaiea ia ciaeaaia.', mbError, MB_OK);

IDCANCEL:;
end
else
if ExpandConstant('{language}') = 'ru' then
case MsgBox('Iaiea "' + ExpandConstant('{app}') + '" ia ionoa.'#13#13 +
'"Aa" – iieiia oaaeaiea anao oaeeia a iaiea, aee??ay naio iaieo.' #13#13 +
'"Iao" – ioe?uou iaieo a i?iaiaieea, ?oiau a?o?io? oaaeeou oaeeu.'#13#13 +
'"Ioiaia" – ie?aai ia aaeaou, oaaeeou iaieo iic?a naiinoiyoaeuii.', mbInformation, MB_YESNOCANCEL) of

IDYES:
if not DelTree(ExpandConstant('{app}'), True, True, True) then
MsgBox('Iaiea ia oaaeaia.' #13#13 'Iaiea eee iaei ec oaeeia a iae caaaenoaiaaiu a?oaei i?eei?aieai.', mbError, MB_OK);

IDNO:
if not ShellExec('open', ExpandConstant('{app}'), '', '', SW_SHOWMAXIMIZED, ewNoWait, Res) then
MsgBox('Ioeaea ioe?uoey.' #13#13 'Iaiea ia iaeaaia.', 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;

procedure InitializeWizard3();
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;

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;

procedure DeinitializeSetup2();
begin
disabledesc();
end;

procedure InitializeWizard4();
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,
'Английская озвучка;'+ // SoundUnit\eng
'Французская озвучка;'+ // SoundUnit\fra
'Немецкая озвучка;'+ // SoundUnit\deu
'Итальянская озвучка;'+ // SoundUnit\ita
'Испанская озвучка;' // SoundUnit\spa
);
end;

var
NeedSize:Integer;
FreeMB, TotalMB: Cardinal;
NeedSpaceLabel: TLabel;
n1: 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 n1:= 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 n1:= 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 n1:= 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 InitializeWizard5();
begin
NeedSize := 6100; //Здесь указывается место для приложения
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 CurPageChanged3(CurPageID: Integer);
begin
if CurPageID=wpSelectDir then
begin
GetNeedSpaceCaption;
if FreeMB < NeedSize then
WizardForm.NextButton.Enabled:=False
ListBoxRefresh
end;
end;

Var
Text: TNewStaticText;

Procedure InitializeWizard6();
begin
Text:=TNewStaticText.Create(WizardForm)
Text.Left:=10 // сдвиг влево
Text.Top:=305 // сдвиг вниз
Text.Color:=WizardForm.Color;
Text.Font.Name:='Courier New' // шрифт
Text.Font.Color:=clGray // цвет шрифта
Text.Caption:='Created by Raf-9600' // надпись
Text.Parent:=WizardForm
end;

procedure CurPageChanged4(CurPageID: Integer);
begin
if (CurPageID = wpWelcome) or (CurPageID = wpFinished) or (CurPageID = wpInstalling) then // скроем надпись на стриницах Приветствия, Завершения (картинку портит) и Установки :)
begin
Text.Visible:= False;
end;

if (CurPageID = wpLicense) or (CurPageID = wpInfoBefore) or (CurPageID = wpSelectDir) then // начиная с любой из этих страниц надпись появится
begin
Text.Visible:= True;
end;
end;

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

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

procedure DeinitializeSetup();
begin
DeinitializeSetup1();
DeinitializeSetup2();
end;

volk1234
27-11-2009, 14:15
STRELOK
Вы пропустили завершающий тег [/code]
поэтому тег и не сработал :)

Serega
27-11-2009, 15:26
volk1234, спасибо, дельное замечание насчёт ;)
A1EXXX, лучше использовать тег , чем , т.к. в первом варианте сохраняется структура скрипта... просто воспринимать легче.

A1EXXX
27-11-2009, 15:49
Serega, поправил :)

Serega
27-11-2009, 15:57
поправил »
Расскажу маленький фокус, чтоб не писать в скрипте [_Code], я делаю [Code]




© OSzone.net 2001-2012