KARB10
Новичок
Привет
Как добавит задача на это кнопка для установка Directx,vc++ ?
Как добавит задача на это кнопка для установка Directx,vc++ ?
Код:
#include "layered.iss"
[Setup]
AppName=Hitman Absolution
AppVerName=Hitman Absolution
DefaultDirName={pf}\Hitman Absolution
MinVersion=0,5.1
OutputDir=userdocs:Inno Setup Examples Output
[Languages]
Name: "ru"; MessagesFile: "compiler:Languages\Russian.isl"
[CustomMessages]
ru.BtnCancel=Отмена
ru.BtnBack=<<< Назад
ru.BtnNext=Далее >>>
ru.BtnInstall=Установить
ru.BtnFinish=Завершить
ru.BtnBrowse=Обзор ...
ru.BtnAga=Ага
ru.BtnNea=Неа
ru.MainWelcome=Добро пожаловать
ru.MainSelectdir=Каталог установки
ru.MainSettings=Дополнительные задачи
ru.MainFinish=Завершение
ru.MsgCancel=Вы действительно хотите отменить установку игры Hitman Absolution?
ru.Welcome=Программа установит игру Hitman Absolution на Ваш компьютер.%n%nРекомендуется закрыть антивирусные пакеты, а также все прочие приложения перед тем, как продолжить.%n%nНажмите «Далее», чтобы продолжить.%n%nНажмите «Отмена», чтобы выйти.
ru.Finish=Игра Hitman Absolution была успешно установлена на Ваш компьютер.%n%nДля ее запуска выберите соответствующий ярлык в меню «Пуск» или на Рабочем столе.%n%nНажмите «Завершить», чтобы выйти из программы установки.
ru.set1=Выберите язык игры:
ru.set2=Выберите дополнительные параметры установки:
ru.ru=Русский язык
ru.en=English
ru.po=Установить дополнительное ПО
[files]
Source: "files\*.*"; flags: dontcopy nocompression;
;Source: "data\*.*"; DestDir: "{app}"
[code]
var
tex_btn, tex_cb, tex_box, tex_pb, tex_btn_close, tex_folder, tex_settings,
Scene, Scene_cancelform,
btn_min, btn_close, btn_back, btn_next, btn_cancel, btn_browse,
btn_close_cancelform, btn_no_cancelform, btn_yes_cancelform,
btn_box1, btn_box2, btn_box3,
dir_edit, pb,
brush_btn_focused, brush_btn_disabled,
str_main, str_welcome, str_finish, str_selectdir, str_params, str_space,
str_box1, str_box2,
img_welcome, img_finish, img_folder, img_settings, img_install: integer;
CancelForm: TSetupForm; cancel_setup, pause_setup: boolean;
procedure OnPaint(Window: TSetupForm); var brush, pen, grad: integer;
begin
brush := lSolidBrushCreate($ee333333);
pen := lSolidBrushCreate($EE5555FF);
// серая форма
lFillRectangle(brush, 0, 0, Window.Width, Window.Height);
// обводка вокруг
lDrawRectangle(pen, 0, 0, Window.Width - 1, Window.Height - 1, 1);
brush := lBrushDelete(brush);
pen := lBrushDelete(pen);
// градиентная линия под заголовком. первая(левая часть)
grad := lGradientBrushCreate(ScaleX(15), ScaleY(25), Window.Width / 2, ScaleY(25), $00222222, $EE5555FF);
lDrawLine(grad, ScaleX(16), ScaleY(25), Window.Width / 2, ScaleY(25), 1);
grad := lBrushDelete(grad);
// вторая(правая часть)
grad := lGradientBrushCreate(Window.Width / 2, ScaleY(25), Window.Width - ScaleX(15), ScaleY(25), $EE5555FF, $00222222);
lDrawLine(grad, Window.Width / 2, ScaleY(25), Window.Width - ScaleX(16), ScaleY(25), 1);
grad := lBrushDelete(grad);
// заголовок окна
lStringAlignment(SA_CENTER);
lStringLineAlignment(SA_CENTER);
lDrawStringRect(SetupMessage(msgSetupAppTitle), 0, 0, Window.Width, ScaleY(30), SCENE_FONT, SCENE_BRUSH);
// текст в окне отмены
if Window = CancelForm then
begin
lStringAlignment(SA_NAER);
lStringLineAlignment(SA_NAER);
lDrawStringRect(ExpandConstant('{cm:MsgCancel}'), ScaleX(20), ScaleY(45), Window.Width - ScaleX(30), Window.Height - ScaleY(20), SCENE_FONT, SCENE_BRUSH);
end;
end;
procedure WizardFormOnPaint(layer: Integer);
begin
OnPaint(WizardForm);
end;
procedure CancelFormOnPaint(layer: Integer);
begin
OnPaint(CancelForm);
end;
function BtnCreate(Window: Integer; X, Y: Integer; Caption: String; Texture: Integer; Event: TEventProc): Integer;
begin
result := lCreateWindow(Window, CW_BTNPUSH, X, Y, Caption, Texture);
lSetWindowLong(result, SWL_EVENTONCLICK, wrapEventProc(Event, 1));
if Caption <> '' then
begin
lSetWindowLong(result, SWL_BRUSHFOCUSED, brush_btn_focused);
lSetWindowLong(result, SWL_BRUSHDISABLED, brush_btn_disabled);
end;
end;
procedure CancelFormOnCancel(window: Integer);
begin
pause_setup := FALSE;
WizardForm.Enabled := TRUE;
CancelForm.Hide;
end;
procedure CancelFormOnOk(window: Integer);
begin
cancel_setup := true;
lSetProgressState(pb, L_ERROR);
lSceneApply(Scene);
CancelForm.Hide;
WizardForm.Enabled := TRUE;
MainForm.Close;
end;
type
TMessage = record hWnd: HWND; msg, wParam: Word; lParam: LongWord; Time: TFileTime; pt: TPoint; end;
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';
procedure AppProcessMessage;
var
Msg: TMessage;
begin
if not PeekMessage(Msg, 0, 0, 0, 1) then Exit;
TranslateMessage(Msg); DispatchMessage(Msg);
end;
procedure OnCancel(window: Integer);
begin
pause_setup := true;
if CancelForm = nil then
begin
CancelForm := CreateCustomForm();
CancelForm.SetBounds(ScaleX(0), ScaleY(0), ScaleX(400), ScaleY(130));
CancelForm.BorderStyle := bsNone;
CancelForm.Caption := SetupMessage(msgExitSetupTitle);
CancelForm.Font := WizardForm.Font;
CancelForm.FormStyle := fsStayOnTop;
Scene_cancelform := lSceneCreate(CancelForm.Handle);
lSceneSetLong(Scene_cancelform, SSL_BRUSH, lSolidBrushCreate($FFAAAAAA));
lSceneSetLong(Scene_cancelform, SSL_FONT, lFontCreate(CancelForm.Font.Handle));
lSceneAddlayer(Scene_cancelform);
lSceneSetLong(Scene_cancelform, SSL_PAINTEVENT, wrapEventProc(@CancelFormOnPaint, 1));
lSceneMoving(Scene_cancelform, 0, 0, ScaleX(45), ScaleY(105));
btn_close_cancelform := BtnCreate(Scene_cancelform, ScaleX(354), ScaleY(1), '', tex_btn_close, @CancelFormOnCancel);
btn_no_cancelform := BtnCreate(Scene_cancelform, ScaleX(280), ScaleY(90), ExpandConstant('{cm:BtnNea}'), tex_btn, @CancelFormOnCancel);
btn_yes_cancelform := BtnCreate(Scene_cancelform, ScaleX(170), ScaleY(90), ExpandConstant('{cm:BtnAga}'), tex_btn, @CancelFormOnOk);
end;
WizardForm.Enabled := FALSE;
CancelForm.Left := WizardForm.Left + ScaleX(100);
CancelForm.Top := WizardForm.Top + ScaleY(150);
CancelForm.Visible := TRUE;
lSceneApply(Scene_cancelform);
if WizardForm.CurPageID = wpInstalling then
begin
lSetProgressState(pb, L_PAUSE);
lSceneApply(Scene);
while CancelForm.Visible do
begin
if cancel_setup then exit;
if not CancelForm.Visible then exit;
AppProcessMessage(); // затормозит установку
end;
end;
end;
procedure OnMin(window: Integer);
begin
PostMessage(WizardForm.Handle, $0112, 61472, 0);
end;
procedure OnBack(window: Integer);
begin
WizardForm.BackButton.OnClick(WizardForm.BackButton);
end;
procedure OnNext(window: Integer);
begin
WizardForm.NextButton.OnClick(WizardForm.NextButton);
end;
procedure OnBrowse(window: Integer);
begin
WizardForm.DirBrowseButton.OnClick(WizardForm.DirBrowseButton);
lSetWindowText(dir_edit, WizardForm.DirEdit.Text);
end;
procedure EditOnChange(window: Integer);
begin
WizardForm.DirEdit.Text := lGetWindowText(window);
end;
procedure OnLang1(window: Integer);
begin
lSetBtnChecked(btn_box1, TRUE);
lSetBtnChecked(btn_box2, FALSE);
end;
procedure OnLang2(window: Integer);
begin
lSetBtnChecked(btn_box2, TRUE);
lSetBtnChecked(btn_box1, FALSE);
end;
procedure InitializeWizard(); var Font: TFont;
begin
ExtractTemporaryFile('layered.dll');
ExtractTemporaryFile('CallbackCtrl.dll');
ExtractTemporaryFile('btn.png');
ExtractTemporaryFile('cb.png');
ExtractTemporaryFile('progress.png');
ExtractTemporaryFile('edit.png');
ExtractTemporaryFile('min.png');
ExtractTemporaryFile('close.png');
ExtractTemporaryFile('f.png');
ExtractTemporaryFile('w.png');
ExtractTemporaryFile('folder.png');
ExtractTemporaryFile('set.png');
ExtractTemporaryFile('c.png');
ExtractTemporaryFile('s0.jpg');
cancel_setup := false;
lStartup();
WizardForm.Width := ScaleX(600);
WizardForm.Height := ScaleY(400);
WizardForm.OuterNotebook.Hide; // обязательно
WizardForm.BorderStyle := bsNone; // обязательно
WizardForm.Bevel.Hide; // обязательно
WizardForm.CancelButton.Width := ScaleX(0); // кнопки лучше скрыть
WizardForm.NextButton.Width := ScaleX(0);
WizardForm.BackButton.Width := ScaleX(0);
WizardForm.Font.Name := 'Lucida Console';
WizardForm.Font.Size := WizardForm.Font.Size + 1;
Font := TFont.Create;
Font.Name := 'Calibri';
Font.Style := [fsBold];
Font.Size := 18;
tex_btn := lTextureCreateW(ExpandConstant('{tmp}\btn.png'));
tex_cb := lTextureCreateW(ExpandConstant('{tmp}\cb.png'));
tex_pb := lTextureCreateW(ExpandConstant('{tmp}\progress.png'));
tex_btn_close := lTextureCreateW(ExpandConstant('{tmp}\close.png'));
tex_settings := lTextureCreateW(ExpandConstant('{tmp}\set.png'));
tex_box := lTextureCreateW(ExpandConstant('{tmp}\c.png'));
tex_folder := lTextureCreateW(ExpandConstant('{tmp}\folder.png'));
brush_btn_focused := lSolidBrushCreate($FFEEEEEE);
brush_btn_disabled := lSolidBrushCreate($FF555555);
Scene := lSceneCreate(WizardForm.Handle);
lSceneSetBrush(Scene, lSolidBrushCreate($FFAAAAAA));
lSceneSetFont(Scene, lFontCreate(WizardForm.Font.Handle));
lSceneAddlayer(Scene);
lSceneSetLong(Scene, SSL_PAINTEVENT, wrapEventProc(@WizardFormOnPaint, 1));
lSceneMoving(Scene, 0, 0, ScaleX(72), ScaleY( 375));
str_main := lStrLoad(Scene, ExpandConstant('{cm:MainWelcome}'), ScaleX(260), ScaleY(50), ScaleX(400), ScaleY(40), FALSE);
lStrSetFont(str_main, lFontCreate(Font.Handle));
str_welcome := lStrLoad(Scene, ExpandConstant('{cm:Welcome}'), ScaleX(260), ScaleY(100), ScaleX(300), ScaleY(300), FALSE);
str_finish := lStrLoad(Scene, ExpandConstant('{cm:Finish}'), ScaleX(27), ScaleY(100), ScaleX(300), ScaleY(300), FALSE);
lStrSetVisibility(str_finish, FALSE);
str_selectdir := lStrLoad(Scene, SetupMessage(msgSelectDirBrowseLabel), ScaleX(85), ScaleY(110), ScaleX(500), ScaleY(50), FALSE);
str_params := lStrLoad(Scene, SetupMessage(msgSelectTasksDesc), ScaleX(85), ScaleY(110), ScaleX(500), ScaleY(50), FALSE);
lStrSetVisibility(str_selectdir, False);
lStrSetVisibility(str_params, False);
str_space := lStrLoad(Scene, WizardForm.DiskSpaceLabel.Caption, ScaleX(27), ScaleY(320), 0, 0, TRUE);
lStrSetVisibility(str_space, False);
img_welcome := lImgLoad(Scene, lTextureCreateW(ExpandConstant('{tmp}\w.png')), ScaleX(5), ScaleY(20), 0, 0, TRUE);
img_finish := lImgLoad(Scene, lTextureCreateW(ExpandConstant('{tmp}\f.png')), ScaleX(290), ScaleY(20), 0, 0, TRUE);
lImgSetVisibility(img_finish, FALSE);
img_folder := lImgLoad(Scene, tex_folder, ScaleX(27), ScaleY(100), ScaleX(45), ScaleY(45), FALSE);
img_settings := lImgLoad(Scene, tex_settings, ScaleX(27), ScaleY(100), ScaleX(45), ScaleY(45), FALSE);
lImgSetVisibility(img_folder, FALSE);
lImgSetVisibility(img_settings, FALSE);
btn_min := BtnCreate(Scene, ScaleX(528), ScaleY(1), '', lTextureCreateW(ExpandConstant('{tmp}\min.png')), @OnMin);
btn_close := BtnCreate(Scene, ScaleX(554), ScaleY(1), '', tex_btn_close, @OnCancel);
btn_back := BtnCreate(Scene, ScaleX(245), ScaleY(360), ExpandConstant('{cm:BtnBack}'), tex_btn, @OnBack);
btn_next := BtnCreate(Scene, ScaleX(357), ScaleY(360), ExpandConstant('{cm:BtnNext}'), tex_btn, @OnNext);
btn_cancel := BtnCreate(Scene, ScaleX(475), ScaleY(360), ExpandConstant('{cm:BtnCancel}'), tex_btn, @OnCancel);
btn_browse := BtnCreate(Scene, ScaleX(465), ScaleY(170), ExpandConstant('{cm:BtnBrowse}'), tex_btn, @OnBrowse);
lSetWindowVisibility(btn_back, FALSE);
lSetWindowVisibility(btn_browse, FALSE);
dir_edit := lCreateWindow(Scene, CW_EDIT, ScaleX(27), ScaleY(170), WizardForm.DirEdit.Text, lTextureCreateW(ExpandConstant('{tmp}\edit.png')));
lSetWindowLong(dir_edit, SWL_EVENTCHANGE, wrapEventProc(@EditOnChange, 1));
lSetWindowLong(dir_edit, SWL_BRUSHDISABLED, brush_btn_disabled);
lSetWindowLong(dir_edit, SWL_BRUSHFOCUSED, brush_btn_focused);
lSetWindowVisibility(dir_edit, FALSE);
str_box1 := lStrLoad(Scene, ExpandConstant('{cm:set1}'), ScaleX(27), ScaleY(170), 0, 0, TRUE);
btn_box1 := lCreateWindow(Scene, CW_BTNCHECK, ScaleX(40), ScaleY(190), ExpandConstant('{cm:ru}'), tex_box);
lSetWindowLong(btn_box1, SWL_EVENTONCLICK, wrapEventProc(@OnLang1, 1));
btn_box2 := lCreateWindow(Scene, CW_BTNCHECK, ScaleX(40), ScaleY(220), ExpandConstant('{cm:en}'), tex_box);
lSetWindowLong(btn_box2, SWL_EVENTONCLICK, wrapEventProc(@OnLang2, 1));
str_box2 := lStrLoad(Scene, ExpandConstant('{cm:set2}'), ScaleX(27), ScaleY(245), 0, 0, TRUE);
btn_box3 := lCreateWindow(Scene, CW_BTNCHECK, ScaleX(40), ScaleY(265), ExpandConstant('{cm:po}'), tex_cb);
lSetBtnChecked(btn_box2, FALSE);
lSetWindowVisibility(btn_box1, FALSE);
lSetWindowVisibility(btn_box2, FALSE);
lSetWindowVisibility(btn_box3, FALSE);
lStrSetVisibility(str_box1, FALSE);
lStrSetVisibility(str_box2, FALSE);
pb := lCreateWindow(Scene, CW_PROGRESS, ScaleX(17), ScaleY(360), '', lTextureCreateW(ExpandConstant('{tmp}\progress.png')))
lSetWindowVisibility(pb, FALSE);
img_install := lImgLoad(Scene, lTextureCreateW(ExpandConstant('{tmp}\s0.jpg')), ScaleX(10), ScaleY(35), 0, 0, TRUE);
lImgSetVisibility(img_install, FALSE);
lSceneApply(Scene);
Font.Free;
end;
procedure CancelButtonClick(CurPageID: Integer; var Cancel, Confirm: Boolean);
begin
Confirm := false;
if cancel_setup then
begin
lSetProgressState(pb, L_ERROR);
lSceneApply(Scene);
end;
Cancel := cancel_setup;
end;
type
TTimerProc = procedure(hwnd: HWND; uMsg: Uint; idEvent: Longint; dwTime: Dword);
function wrapTimerProc(callback: TTimerProc; paramcount: integer): longword;external 'wrapcallbackaddr@{tmp}\callbackctrl.dll stdcall delayload';
function SetTimer(hwnd: HWND; nIDEvent: Longint; uElapse: Uint; lpTimerFunc: Longint): Longint; external 'SetTimer@user32';
function KillTimer(hwnd: HWND; nIDEvent: Longint): Bool; external 'KillTimer@user32';
procedure UpdateOnTimer(hwnd: HWND; uMsg: Uint; idEvent: Longint; dwTime: Dword);
var
Value: Integer;
begin
Value := WizardForm.ProgressGauge.Position * 100 div WizardForm.ProgressGauge.Max;
if not pause_setup then
begin
lSetProgressValue(pb, Value);
//if (Value = 20) then begin ImgSetVisible(Slides[0], FALSE); ImgSetVisible(Slides[1], TRUE); end;
//if (Value = 40) then begin ImgSetVisible(Slides[1], FALSE); ImgSetVisible(Slides[2], TRUE); end;
//if (Value = 60) then begin ImgSetVisible(Slides[2], FALSE); ImgSetVisible(Slides[3], TRUE); end;
//if (Value = 80) then begin ImgSetVisible(Slides[3], FALSE); ImgSetVisible(Slides[4], TRUE); end;
lSceneApply(Scene);
end;
end;
procedure CurPageChanged(CurPageID: Integer);
begin
lSetWindowText(btn_next, ExpandConstant('{cm:BtnNext}'));
lSetWindowVisibility(dir_edit, FALSE);
lSetWindowVisibility(btn_browse, FALSE);
lImgSetVisibility(img_folder, FALSE);
lImgSetVisibility(img_settings, FALSE);
lStrSetVisibility(str_selectdir, FALSE);
lStrSetVisibility(str_params, FALSE);
lStrSetVisibility(str_space, FALSE);
lSetWindowVisibility(btn_box1, FALSE);
lSetWindowVisibility(btn_box2, FALSE);
lSetWindowVisibility(btn_box3, FALSE);
lStrSetVisibility(str_box1, FALSE);
lStrSetVisibility(str_box2, FALSE);
case CurPageID of
wpWelcome: begin
lStrSetVisibility(str_welcome, TRUE);
lImgSetVisibility(img_welcome, TRUE);
lStrSetPosition(str_main, ScaleX(260), ScaleY(50), ScaleX(300), ScaleY(30));
lStrSetCaption(str_main, ExpandConstant('{cm:MainWelcome}'));
lSetWindowVisibility(btn_back, FALSE);
end;
wpSelectDir: begin
lStrSetVisibility(str_welcome, FALSE);
lImgSetVisibility(img_welcome, FALSE);
lStrSetPosition(str_main, ScaleX(27), ScaleY(50), ScaleX(300), ScaleY(30));
lStrSetCaption(str_main, ExpandConstant('{cm:MainSelectdir}'));
lImgSetVisibility(img_folder, TRUE);
lStrSetVisibility(str_selectdir, TRUE);
lStrSetVisibility(str_space, TRUE);
lSetWindowVisibility(dir_edit, TRUE);
lSetWindowVisibility(btn_back, TRUE);
lSetWindowVisibility(btn_browse, TRUE);
end;
wpReady: begin
lStrSetVisibility(str_params, TRUE);
lImgSetVisibility(img_settings, TRUE);
lStrSetCaption(str_main, ExpandConstant('{cm:MainSettings}'));
lSetWindowText(btn_next, ExpandConstant('{cm:BtnInstall}'));
lSetWindowVisibility(btn_box1, TRUE);
lSetWindowVisibility(btn_box2, TRUE);
lSetWindowVisibility(btn_box3, TRUE);
lStrSetVisibility(str_box1, TRUE);
lStrSetVisibility(str_box2, TRUE);
end;
wpInstalling: begin
SetTimer(WizardForm.Handle, 2240, 30, wrapTimerProc(@UpdateOnTimer, 4));
lSetWindowVisibility(pb, TRUE);
lImgSetVisibility(img_install, TRUE);
lStrSetVisibility(str_main, FALSE);
lSetWindowVisibility(btn_back, FALSE);
lSetWindowVisibility(btn_next, FALSE);
end;
wpFinished: begin
KillTimer(WizardForm.Handle, 2240);
lSetWindowVisibility(pb, FALSE);
lImgSetVisibility(img_install, FALSE);
lStrSetVisibility(str_finish, TRUE);
lImgSetVisibility(img_finish, TRUE);
lStrSetVisibility(str_main, TRUE);
lStrSetCaption(str_main, ExpandConstant('{cm:MainFinish}'));
lSetWindowVisibility(btn_cancel, FALSE);
lSetWindowText(btn_next, ExpandConstant('{cm:BtnFinish}'));
lSetWindowPos(btn_next, lGetWindowPos(btn_cancel).Left, lGetWindowPos(btn_cancel).Top);
lSetWindowVisibility(btn_next, TRUE);
lSetWindowEnabled(btn_close, FALSE);
end;
end;
lSceneApply(Scene);
end;
procedure DeinitializeSetup();
begin
lShutdown;
end;
procedure CurStepChanged(CurStep: TSetupStep);
begin
if CurStep = ssPostInstall then
begin
if lGetBtnChecked(btn_box1) then MsgBox('Rus', mbInformation, MB_OK);
if lGetBtnChecked(btn_box2) then MsgBox('Eng', mbInformation, MB_OK);
if lGetBtnChecked(btn_box3) then MsgBox('ПО Установлено', mbInformation, MB_OK);
end;
end;
Последнее редактирование модератором: