Проблема Помогите добавить проверку памяти на диске.

EvilAlex

Старожил
Есть какой-то скрипт типа от гога. Пытался его переделать, но не могу прикрутить отображение размера диска и сколько надо места.
У меня сейчас вот так:
Снимок.PNG

А хочу сделать так:
Снимок2.png

Но я не могу понять, все делаю вроде как надо, но ни чего не отображается. Взял от старого сетапа модуль и попытался прикрутить. тоже не получается. Максимум что смог сделать, это отображение иконки no.bmp и надписи Доступно: ...

почему не отображается размер, сколько доступно и сколько надо, просто не понимаю.
 

Вложения

  • 1.5 MB Просмотры: 26

Nemko

Дилетант
Модератор
EvilAlex, сложно сказать конкретно, попробуйте "откомпилить" грубый пример, у меня работает. Внедренный код из FAQ автор Shegorat, проверено временем.

Код:
; ______  __   __      _______ _    _ _____        _______        _______ _     _
; |_____]   \_/        |______  \  /    |   |      |_____| |      |______  \___/
; |_____]    |         |______   \/   __|__ |_____ |     | |_____ |______ _/   \_
;
; Verison Script 1.2.5 - 29.11.2020.

#ifdef UNICODE
  #define A "W"
#else
  #define A "A"
#endif
#ifndef IS_ENHANCED
  #error Enhanced edition of Inno Setup (restools) is required to compile this script
#endif

#define Font        "Play.ttf"
#define FontName    "Play"
#define Font2       "Play-Bold.ttf"
#define FontName2   "Play Bold"
#define AppName     "Загатовка"
#define Publisher   "EvilAlex"
#define AppInfoVer  "1.0.75.0"
#define AppVer      "1.05"
#define AppExe      "unins000.exe"

#define NeedSize        4380
#define NeedInstallSize 7890

[Setup]
AppName={#AppName}
AppVersion={#AppVer}
VersionInfoVersion={#AppInfoVer}
//AppVerName={#AppName}{#AppVer}
AppCopyright=Repack by {#Publisher}
AppPublisher=Repack by {#Publisher}
VersionInfoDescription={#AppName}_Setup

DefaultDirName={sd}\Games\{#AppName}
DefaultGroupName={#AppName}
DirExistsWarning=no

UninstallFilesDir={app}
SetupIconFile=Files\inicon.ico
UninstallIconFile=Files\unicon.ico
UninstallDisplayIcon={app}\{#AppExe}
//RawDataResource=font:Files\{#Font} | font2:Files\{#Font2}

OutputDir=Output
OutputBaseFilename=Setup_{#AppName}

InternalCompressLevel=ultra64
Compression=lzma2/ultra64
SolidCompression=true

DisableReadyPage=true
DisableProgramGroupPage=true
ShowComponentSizes=false


[Icons]
Name: "{commondesktop}\{#AppName}"; Filename: "{app}\{#AppExe}"; IconFilename: {app}\{#AppExe};

[Files]
Source: Files\{#Font}; Flags: dontcopy
Source: Files\{#Font2}; Flags: dontcopy
Source: Files\InnoCallback.dll; Flags: dontcopy
Source: Files\bg.bmp; Flags: dontcopy
Source: Files\logo.bmp; Flags: dontcopy
Source: Files\*.bmp; DestDir: "{tmp}"; Flags: dontcopy
Source: Dll\WinTB.dll; Flags: dontcopy
Source: Dll\*.dll; DestDir: "{tmp}"; Flags: dontcopy
Source: Files\inicon.ico; DestDir: "{app}";

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

[CustomMessages]
russian.setupname   ={#AppName}
russian.aboutbutton =Опции
russian.NextButton  =Установить
russian.FinButton   =Завершить
russian.EndButton   =Отменить
russian.StartButton =Играть

russian.WelcomeLabel=Добро пожаловать! Вы собираетесь начать установку
russian.WelcomeLabel2=Рекомендуется закрыть антивирусные пакеты%nи все прочие приложения перед тем, как продолжить.%nНажмите «Далее», что бы продолжить установку, или «Выход»,%nчтобы выйти из программы установки.
russian.WelcomeLabel3=Идет установка, Ждите...
russian.WelcomeLabel4=Игра была успешно установлена на ваш компьютер.%nПриложение можно запустить с помощью соответствующего значка%nна «Рабочем Столе» или меню «Пуск».
russian.WelcomeLabel5=Установка не была завершена.%nПожалуйста, устраните проблему и запустите установку снова.

russian.Dirlabel=Программа установит игру в следующую папку.
russian.Grouplabel=Программа создаст ярлыки в следующей папке меню «Пуск».

russian.Uninstall=Удаление - «{#AppName}»
russian.StatusUninstall=Пожалуйста ждите!%n%nИдет удаление компонентов игры...

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

[*Code]
#include "WinTB.iss"
#include "Uninstall.iss"
//=-=-=-=-=-=-=-=-=-=-=-
var
ShowBtn,StartButton: TNewButton;
Flag: boolean;

p0,p1,p2,p3: TPanel;
BVL:TBevel;

WelcomeLabel,WelcomeLabel1,WelcomeLabel2,Dirlabel,Dirlabel2,Grouplabel,Iconslabel,Compslabel,Statuslabel,Label1,L1: TLabel;
//=-=-=-=-=-=-=-=-=-=-=-
const
FR_PRIVATE = $10;
//=-=-=-=-=-=-=-=-=-=-=-
function AddFontResource(lpszFilename: String; fl, pdv: DWORD): Integer; external 'AddFontResourceExW@gdi32.dll stdcall';
function RemoveFontResource(lpFileName: String; fl, pdv: DWORD): BOOL; external 'RemoveFontResourceExW@gdi32.dll stdcall';
//=-=-=-=-=-=-=-=-=-=-=-
var
  TotalSpaceLabel, FreeSpaceLabel, NeedSpacelabel, InstallSpaceLabel: TLabel;
  FreeMB, TotalMB: Cardinal;

function NumToStr(Float: Extended): String;
begin
  Result:= Format('%.2f', [Float]);
  StringChange(Result, ',', '.');
  while ( Pos('.', Result) > 0 ) and ( (Result[Length(Result)] = '0') or (Result[Length(Result)] = '.') ) do SetLength(Result, Length(Result) - 1);
end;

function MbOrTb(Float: Extended): String;
begin
  if Float < 1024 then Result:= NumToStr(Float)+' Мб' else
  if Float/1024 < 1024 then Result:= NumToStr(Float/1024)+' Гб' else
  Result:= NumToStr(Float/(1024*1024))+' Тб';
end;

procedure DirEditOnChange(Sender: TObject);
var
  Drive: String;
begin
  Drive:= ExtractFileDrive(WizardForm.DirEdit.Text);
  GetSpaceOnDisk(Drive, True, FreeMB, TotalMB);
  Dirlabel2.Caption:='Всего на HDD: '+MbOrTb(TotalMB)+#13+
             'Доступно: '+MbOrTb(FreeMB)+' ('+IntToStr(round(FreeMB*100/TotalMB))+'%)'+#13+
             'Нужно для распаковки: '+MbOrTb({#NeedInstallSize})+#13+
             'Требуется места: '+MbOrTb({#NeedSize});
  //WizardForm.NextButton.Enabled:= (FreeMB>{#NeedInstallSize})and(FreeMB>{#NeedSize});
end;
//=-=-=-=-=-=-=-=-=-=-=-
procedure ActivateClick(Sender: TObject);
begin
p0.Show;
L1.Show;
p1.Show;
p2.Show;
ShowBtn.Hide;
WelcomeLabel.Hide;
WelcomeLabel1.Hide;
WelcomeLabel2.Hide;
StartButton.Hide;
Wizardform.NextButton.Enabled := true;
Wizardform.BackButton.Enabled := False;
WizardForm.WizardBitmapImage2.Hide;
DirEditOnChange(nil)
end;
//=-=-=-=-=-=-=-=-=-=-=-
procedure HideComponents();
begin
p0.Hide;
L1.Hide;
p1.Hide;
p2.Hide;
p3.Hide;
WelcomeLabel.Hide;
WelcomeLabel1.Hide;
WelcomeLabel2.Hide;
StartButton.Hide;
WizardForm.WizardBitmapImage2.Hide;
end;
//=-=-=-=-=-=-=-=-=-=-=-
procedure CancelButtonClick(CurPageID: Integer; var Cancel, Confirm: Boolean);
begin
Confirm:=False;
end;
//=-=-=-=-=-=-=-=-=-=-=-
function InitializeSetup:boolean;
begin
ExtractTemporaryFile('bg.bmp');
ExtractTemporaryFile('logo.bmp');
  if not FileExists(ExpandConstant('{tmp}\WinTB.dll')) then ExtractTemporaryFile('WinTB.dll');
Result:=True;
end;
//=-=-=-=-=-=-=-=-=-=-=-
procedure CenterInParent(Control: TControl);
begin
  if Assigned(Control) and Assigned(Control.Parent) then
  begin
    Control.Left := (Control.Parent.Width - Control.Width) div 2;
  end;
end;
//=-=-=-=-=-=-=-=-=-=-=-
procedure StartButtonClick(Sender: TObject);
var
  ResultCode: Integer;
begin
    WizardForm.NextButton.OnClick(nil);
  begin
    ExecAsOriginalUser(ExpandConstant('{app}\{#AppExe}'), '', '',
    SW_SHOWNORMAL, ewNoWait, ResultCode);
  end;
end;
//=-=-=-=-=-=-=-=-=-=-=-

procedure WZ();
begin with WizardForm do begin

Flag:= True;

WizardForm.WizardBitmapImage.Bitmap.LoadFromFile(ExpandConstant('{tmp}\bg.bmp'));;
WizardForm.WizardBitmapImage.Stretch:=True;
WizardForm.WizardBitmapImage.Parent:=WizardForm;
WizardForm.WizardBitmapImage.SetBounds(0,0,WizardForm.ClientWidth,355);

WizardForm.WizardBitmapImage2.AutoSize := True;
WizardForm.WizardBitmapImage2.Top:=25;
WizardForm.WizardBitmapImage2.Left:=300;
WizardForm.WizardBitmapImage2.Bitmap.LoadFromFile(ExpandConstant('{tmp}\logo.bmp'));
WizardForm.WizardBitmapImage2.Parent:=WizardForm;

p0:= TPanel.Create(WizardForm);
p0.Parent := WizardForm;
p0.SetBounds(0,0,WizardForm.ClientWidth,WizardForm.ClientHeight-405);
p0.BevelOuter := bvNone;

L1 := TLabel.Create(WizardForm);
L1.Parent := WizardForm;
L1.Caption :=ExpandConstant('Параметры Установки');
L1.SetBounds(30,30,600,100);
L1.AutoSize:= false;
L1.Alignment := taCenter;
L1.Font.Size:=16;
L1.Font.Name := '{#FontName2}';
L1.Transparent:= True;

WizardForm.Bevel.SetBounds(0,355,660,1);

WizardForm.CancelButton.SetBounds(567,366,85,30);
WizardForm.CancelButton.Font.Size:=9;
WizardForm.CancelButton.Font.Name:='{#FontName}';

WizardForm.NextButton.SetBounds(567,366,85,30);
WizardForm.NextButton.Font.Size:=10;
WizardForm.NextButton.Font.Name:='{#FontName}';

ShowBtn := TNewButton.Create(WizardForm);
ShowBtn.Parent := WizardForm;
ShowBtn.SetBounds(8,366,60,30);
ShowBtn.Caption :=ExpandConstant('{cm:aboutbutton}');
ShowBtn.OnClick := @ActivateClick
ShowBtn.Font.Name:='{#FontName}';
ShowBtn.Font.Size:=10;
end;
p1 := TPanel.Create(WizardForm);
p1.Parent := WizardForm;
p1.SetBounds(10,92,642,136);
p1.BevelInner := bvSpace;
p1.BevelOuter := bvLowered;
p1.ParentBackground := False;
p1.Color := 13948116;

p2 := TPanel.Create(WizardForm);
p2.Parent := WizardForm;
p2.SetBounds(10,243,642,96);
p2.BevelInner := bvSpace;
p2.BevelOuter := bvLowered;
p2.ParentBackground := False;
p2.Color := 13948116;

p3 := TPanel.Create(WizardForm);
p3.Parent := WizardForm;
p3.SetBounds(10,159,642,180);
p3.BevelInner := bvSpace;
p3.BevelOuter := bvLowered;
p3.ParentBackground := False;
p3.Color := 13948116;

  StartButton := TNewButton.Create(WizardForm);
  with StartButton do
  begin
    Parent := WizardForm;
    Font.Name:='{#FontName}';
    Font.Size:=10;
    SetBounds(8,366,60,30);
    Caption:=ExpandConstant('{cm:StartButton}');
    OnClick:=@StartButtonClick;
  end;
//=-=-=-=-=-=-=-=-=-=-=-
  WelcomeLabel:= TLabel.Create(WizardForm);
  with WelcomeLabel do
  begin
    AutoSize:= false;
    Parent := WizardForm;
    Alignment := taCenter;
    Font.Size:=14;
    SetBounds(30,120,600,100);
    Caption :=ExpandConstant('{cm:WelcomeLabel}');
    Font.Name := '{#FontName}';
    Transparent:= True;
  end;

  WelcomeLabel1:= TLabel.Create(WizardForm);
  with WelcomeLabel1 do
  begin
    AutoSize:= false;
    Parent := WizardForm;
    Alignment := taCenter;
    Font.Size:=16;
    SetBounds(30,150,600,100);
    Caption := '{#AppName}';
    Font.Name := '{#FontName2}';
    Transparent:= True;
  end;

  WelcomeLabel2:= TLabel.Create(WizardForm);
  with WelcomeLabel2 do
  begin
    Parent := WizardForm;
    AutoSize:= false;
    Font.Name := '{#FontName}';
    Font.Size:=10;
    Alignment := taCenter;
    Transparent:= true;
    WordWrap:= true;
    Top :=WelcomeLabel1.Top+ScaleY(80);
    Left := ScaleX(30);
    Width := ScaleX(600);
    Height := ScaleX(200);
    Caption :=ExpandConstant('{cm:WelcomeLabel2}');
  end;
//=-=-=-=-=-=-=-=-=-=-=-
  Dirlabel:= TLabel.Create(WizardForm);
  with Dirlabel do
  begin
    Parent := p1;
    Left := ScaleY(8);
    Top := ScaleX(13);
    Font.Name := '{#FontName2}';
    Caption :=ExpandConstant('{cm:Dirlabel}');
    Transparent:= True;
  end;

  Dirlabel2:= TLabel.Create(WizardForm);
  with Dirlabel2 do
  begin
    Parent := p1;
    WordWrap := False;
    AutoSize := False;
    Left := ScaleY(480);
    Top := ScaleX(5);
    Width := ScaleX(156);
    Height := ScaleY(124);
    Font.Name := '{#FontName2}';
    Transparent:= True;
    Layout:=tlCenter;
  end;

  with WizardForm.DirEdit do
  begin
    Parent := p1;
    Top := ScaleY(40);
    Left := ScaleX(20);
    Width := ScaleX(360);
    Font.Name := '{#FontName2}';
    Font.Color := clGreen;
    OnChange:=@DirEditOnChange;
  end;

  with WizardForm.DirBrowseButton do
  begin
    Parent := p1;
    Top := WizardForm.DirEdit.Top+ScaleY(-1);
    Left := WizardForm.DirEdit.Width+WizardForm.DirEdit.Left+ScaleX(20);
    Width := ScaleX(72);
    Height := ScaleY(24);
    Font.Name := '{#FontName2}';
    //Font.Size:= {#FontButton};
  end;

  Grouplabel:= TLabel.Create(WizardForm);
  with Grouplabel do
  begin
    Parent := p1;
    Left := ScaleY(8);
    Top := WizardForm.DirEdit.Top+WizardForm.DirEdit.Height+ScaleY(12);
    Font.Name := '{#FontName2}';
    Caption :=ExpandConstant('{cm:Grouplabel}');
    Transparent:= True;
  end;

  with WizardForm.GroupEdit do
  begin
    Parent := p1;
    Top := WizardForm.DirEdit.Top+ScaleY(60);
    Left := ScaleX(20);
    Width := ScaleX(360);
    Font.Name := '{#FontName2}';
    Font.Color := clGreen;
  end;

  with WizardForm.GroupBrowseButton do
  begin
    Parent := p1;
    Top := WizardForm.GroupEdit.Top+ScaleY(-1);
    Left := WizardForm.GroupEdit.Width+WizardForm.GroupEdit.Left+ScaleX(20);
    Width := ScaleX(72);
    Height := ScaleY(24);
    Font.Name := '{#FontName2}';
//  Font.Size:= {#FontButton};
  end;
end;

//=-=-=-=-=-=-=-=-=-=-=-
procedure InitializeWizard;
begin
if not FontExists('{#FontName}') then
begin
ExtractTemporaryFile('{#Font}');
AddFontResource(ExpandConstant('{tmp}\{#Font}'), FR_PRIVATE, 0);
ExtractTemporaryFile('{#Font2}');
AddFontResource(ExpandConstant('{tmp}\{#Font2}'), FR_PRIVATE, 0);
end;
WizardForm.Font.Name := '{#FontName}';
with WizardForm do begin
Caption:='{#AppName}';
Color:=$00D3D3D3;
Position:=poScreenCenter;
InnerNotebook.Hide;
OuterNotebook.Hide;
ClientWidth:=660;
ClientHeight:=405;
//BorderStyle := bsDialog;
WZ();
  Win7TaskBar20();
end;
end;
//=-=-=-=-=-=-=-=-=-=-=-
procedure CurPageChanged(CurPageID: Integer);
begin
HideComponents;
Wizardform.NextButton.Enabled := False;

case CurPageID of

wpWelcome:
begin
WelcomeLabel.Show;
WelcomeLabel1.Show;
WelcomeLabel2.Show;
WizardForm.WizardBitmapImage2.Show;
WizardForm.NextButton.Caption:=ExpandConstant('{cm:NextButton}');
end;

wpSelectDir:
begin
p1.Show;
p2.Show;
WizardForm.WizardBitmapImage2.Hide;
WizardForm.NextButton.Caption:=ExpandConstant('{cm:NextButton}');
end;

wpInstalling:
begin
p3.Show;
L1.Show;
L1.SetBounds(30,100,600,100);
L1.Caption:=ExpandConstant('{cm:WelcomeLabel3}');
WizardForm.WizardBitmapImage2.Show;
WizardForm.CancelButton.Caption:=ExpandConstant('{cm:EndButton}');
end;

wpfinished:
begin
WelcomeLabel1.Show;
WelcomeLabel1.Caption:='{#AppName}';
WelcomeLabel2.Show;
WelcomeLabel2.Caption:=ExpandConstant('{cm:WelcomeLabel4}');
Wizardform.NextButton.Enabled := True;
WizardForm.NextButton.Caption:=ExpandConstant('{cm:FinButton}');
WizardForm.WizardBitmapImage2.Show;
StartButton.Show;
end;
end;
end;
//=-=-=-=-=-=-=-=-=-=-=-
function ShouldSkipPage(PageID: Integer): Boolean;
begin
if (PageID=6)or (PageID=7)or (PageID=8)or (PageID=10)
then Result:=true;
end;
//=-=-=-=-=-=-=-=-=-=-=-
procedure DeinitializeSetup;
begin
RemoveFontResource(ExpandConstant('{tmp}\{#Font}'), FR_PRIVATE, 0);
RemoveFontResource(ExpandConstant('{tmp}\{#Font2}'), FR_PRIVATE, 0);
WizardForm.Free;
end;
//=-=-=-=-=-=-=-=-=-=-=-
 

ffmla

Участник
@EvilAlex ,
You didn't add your NSize.iss in your main code.Also you didn't add the respective labels and images creation procedures.Thats why it doesn't shows. :pleasantry: .
 

EvilAlex

Старожил
Всем здорова, решил не создавать новую тему а спросить тут. Как мне сделать такую же кнопку "Опции" ? чтоб при нажатии открывалась страница (панель на которой можно сделать все лейблы, кнопки, чекбоксы и тд) с выбором папок и ярлыков? а то в этом скрипте надо все модули переписывать под него, у меня ума не хватает пока, чет туплю жостко)
 
Последнее редактирование:

vint56

Ветеран
Проверенный
@EvilAlex

; ______ __ __ _______ _ _ _____ _______ _______ _ _
; |_____] \_/ |______ \ / | | |_____| | |______ \___/
; |_____] | |______ \/ __|__ |_____ | | |_____ |______ _/ \_
;
; Verison Script 1.2.5 - 29.11.2020.

#ifdef UNICODE
#define A "W"
#else
#define A "A"
#endif
#ifndef IS_ENHANCED
#error Enhanced edition of Inno Setup (restools) is required to compile this script
#endif

#define Font "Play.ttf"
#define FontName "Play"
#define Font2 "Play-Bold.ttf"
#define FontName2 "Play Bold"
#define AppName "Загатовка"
#define Publisher "EvilAlex"
#define AppInfoVer "1.0.75.0"
#define AppVer "1.05"
#define AppExe "unins000.exe"

#define NeedSize 4380
#define NeedInstallSize 7890

[Setup]
AppName={#AppName}
AppVersion={#AppVer}
VersionInfoVersion={#AppInfoVer}
//AppVerName={#AppName}{#AppVer}
AppCopyright=Repack by {#Publisher}
AppPublisher=Repack by {#Publisher}
VersionInfoDescription={#AppName}_Setup

DefaultDirName={sd}\Games\{#AppName}
DefaultGroupName={#AppName}
DirExistsWarning=no

UninstallFilesDir={app}
SetupIconFile=Files\inicon.ico
UninstallIconFile=Files\unicon.ico
UninstallDisplayIcon={app}\{#AppExe}
//RawDataResource=font:Files\{#Font} | font2:Files\{#Font2}

OutputDir=Output
OutputBaseFilename=Setup_{#AppName}

InternalCompressLevel=ultra64
Compression=lzma2/ultra64
SolidCompression=true

DisableReadyPage=true
DisableProgramGroupPage=true
ShowComponentSizes=false


[Icons]
Name: "{commondesktop}\{#AppName}"; Filename: "{app}\{#AppExe}"; IconFilename: {app}\{#AppExe};

[Files]
Source: Files\{#Font}; Flags: dontcopy
Source: Files\{#Font2}; Flags: dontcopy
Source: Files\InnoCallback.dll; Flags: dontcopy
Source: Files\bg.bmp; Flags: dontcopy
Source: Files\logo.bmp; Flags: dontcopy
Source: Files\*.bmp; DestDir: "{tmp}"; Flags: dontcopy
Source: Dll\WinTB.dll; Flags: dontcopy
Source: Dll\*.dll; DestDir: "{tmp}"; Flags: dontcopy
Source: Files\inicon.ico; DestDir: "{app}";

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

[CustomMessages]
russian.setupname ={#AppName}
russian.aboutbutton =Опции
russian.NextButton =Установить
russian.FinButton =Завершить
russian.EndButton =Отменить
russian.StartButton =Играть

russian.WelcomeLabel=Добро пожаловать! Вы собираетесь начать установку
russian.WelcomeLabel2=Рекомендуется закрыть антивирусные пакеты%nи все прочие приложения перед тем, как продолжить.%nНажмите «Далее», что бы продолжить установку, или «Выход»,%nчтобы выйти из программы установки.
russian.WelcomeLabel3=Идет установка, Ждите...
russian.WelcomeLabel4=Игра была успешно установлена на ваш компьютер.%nПриложение можно запустить с помощью соответствующего значка%nна «Рабочем Столе» или меню «Пуск».
russian.WelcomeLabel5=Установка не была завершена.%nПожалуйста, устраните проблему и запустите установку снова.

russian.Dirlabel=Программа установит игру в следующую папку.
russian.Grouplabel=Программа создаст ярлыки в следующей папке меню «Пуск».

russian.Uninstall=Удаление - «{#AppName}»
russian.StatusUninstall=Пожалуйста ждите!%n%nИдет удаление компонентов игры...

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

Код:
#include "WinTB.iss"
#include "Uninstall.iss"
//=-=-=-=-=-=-=-=-=-=-=-
var
ShowBtn,StartButton: TNewButton;
Flag: boolean;

p0,p1,p2,p3: TPanel;
BVL:TBevel;
Options: TNewButton;
PanelOptions: TPanel;
Soft: TNewCheckBox;
Desktop: TNewCheckBox;

WelcomeLabel,WelcomeLabel1,WelcomeLabel2,Dirlabel,Dirlabel2,Grouplabel,Iconslabel,Compslabel,Statuslabel,Label1,L1: TLabel;
//=-=-=-=-=-=-=-=-=-=-=-
const
FR_PRIVATE = $10;
//=-=-=-=-=-=-=-=-=-=-=-
function AddFontResource(lpszFilename: String; fl, pdv: DWORD): Integer; external 'AddFontResourceExW@gdi32.dll stdcall';
function RemoveFontResource(lpFileName: String; fl, pdv: DWORD): BOOL; external 'RemoveFontResourceExW@gdi32.dll stdcall';
//=-=-=-=-=-=-=-=-=-=-=-
var
  TotalSpaceLabel, FreeSpaceLabel, NeedSpacelabel, InstallSpaceLabel: TLabel;
  FreeMB, TotalMB: Cardinal;

function NumToStr(Float: Extended): String;
begin
  Result:= Format('%.2f', [Float]);
  StringChange(Result, ',', '.');
  while ( Pos('.', Result) > 0 ) and ( (Result[Length(Result)] = '0') or (Result[Length(Result)] = '.') ) do SetLength(Result, Length(Result) - 1);
end;

function MbOrTb(Float: Extended): String;
begin
  if Float < 1024 then Result:= NumToStr(Float)+' Мб' else
  if Float/1024 < 1024 then Result:= NumToStr(Float/1024)+' Гб' else
  Result:= NumToStr(Float/(1024*1024))+' Тб';
end;

procedure DirEditOnChange(Sender: TObject);
var
  Drive: String;
begin
  Drive:= ExtractFileDrive(WizardForm.DirEdit.Text);
  GetSpaceOnDisk(Drive, True, FreeMB, TotalMB);
  Dirlabel2.Caption:='Всего на HDD: '+MbOrTb(TotalMB)+#13+
             'Доступно: '+MbOrTb(FreeMB)+' ('+IntToStr(round(FreeMB*100/TotalMB))+'%)'+#13+
             'Нужно для распаковки: '+MbOrTb({#NeedInstallSize})+#13+
             'Требуется места: '+MbOrTb({#NeedSize});
  //WizardForm.NextButton.Enabled:= (FreeMB>{#NeedInstallSize})and(FreeMB>{#NeedSize});
end;
//=-=-=-=-=-=-=-=-=-=-=-
procedure ActivateClick(Sender: TObject);
begin
p0.Show;
L1.Show;
p1.Show;
p2.Show;
ShowBtn.Hide;
Options.Show;
PanelOptions.Show;
WelcomeLabel.Hide;
WelcomeLabel1.Hide;
WelcomeLabel2.Hide;
StartButton.Hide;
Wizardform.NextButton.Enabled := true;
Wizardform.BackButton.Enabled := False;
WizardForm.WizardBitmapImage2.Hide;
DirEditOnChange(nil)
PanelOptions.Hide;
end;
//=-=-=-=-=-=-=-=-=-=-=-
procedure HideComponents();
begin
p0.Hide;
L1.Hide;
p1.Hide;
p2.Hide;
p3.Hide;
WelcomeLabel.Hide;
WelcomeLabel1.Hide;
WelcomeLabel2.Hide;
StartButton.Hide;
WizardForm.WizardBitmapImage2.Hide;
Options.Hide;
//PanelOptions.Hide;

end;
//=-=-=-=-=-=-=-=-=-=-=-
procedure CancelButtonClick(CurPageID: Integer; var Cancel, Confirm: Boolean);
begin
Confirm:=False;
end;
//=-=-=-=-=-=-=-=-=-=-=-
function InitializeSetup:boolean;
begin
ExtractTemporaryFile('bg.bmp');
ExtractTemporaryFile('logo.bmp');
  if not FileExists(ExpandConstant('{tmp}\WinTB.dll')) then ExtractTemporaryFile('WinTB.dll');
Result:=True;
end;
//=-=-=-=-=-=-=-=-=-=-=-
procedure CenterInParent(Control: TControl);
begin
  if Assigned(Control) and Assigned(Control.Parent) then
  begin
    Control.Left := (Control.Parent.Width - Control.Width) div 2;
  end;
end;
//=-=-=-=-=-=-=-=-=-=-=-
procedure StartButtonClick(Sender: TObject);
var
  ResultCode: Integer;
begin
    WizardForm.NextButton.OnClick(nil);
  begin
    ExecAsOriginalUser(ExpandConstant('{app}\{#AppExe}'), '', '',
    SW_SHOWNORMAL, ewNoWait, ResultCode);
  end;
end;
//=-=-=-=-=-=-=-=-=-=-=-

procedure OptionsClick(Sender: TObject);
begin
  case TButton(Sender).Tag of
   0: begin
      TButton(Sender).Tag := 1;
      TButton(Sender).Caption := 'Показать';
      PanelOptions.Show;
      //PanelOptions.Hide;
      Soft.Show;
      Desktop.Show;
      end;
   1: begin
      TButton(Sender).Tag := 0;
      TButton(Sender).Caption := 'Скрыть';
      PanelOptions.Hide;
      //PanelOptions.Show;
      Soft.Hide;
      Desktop.Hide;
      end;
  end;
end;

function SoftCheck: Boolean;
begin
  Result := Soft.Checked;
end;
function DesktopCheck: Boolean;
begin
  Result := Desktop.Checked;
end;

procedure WZ();
begin with WizardForm do begin

Flag:= True;

WizardForm.WizardBitmapImage.Bitmap.LoadFromFile(ExpandConstant('{tmp}\bg.bmp'));;
WizardForm.WizardBitmapImage.Stretch:=True;
WizardForm.WizardBitmapImage.Parent:=WizardForm;
WizardForm.WizardBitmapImage.SetBounds(0,0,WizardForm.ClientWidth,355);

WizardForm.WizardBitmapImage2.AutoSize := True;
WizardForm.WizardBitmapImage2.Top:=25;
WizardForm.WizardBitmapImage2.Left:=300;
WizardForm.WizardBitmapImage2.Bitmap.LoadFromFile(ExpandConstant('{tmp}\logo.bmp'));
WizardForm.WizardBitmapImage2.Parent:=WizardForm;

p0:= TPanel.Create(WizardForm);
p0.Parent := WizardForm;
p0.SetBounds(0,0,WizardForm.ClientWidth,WizardForm.ClientHeight-405);
p0.BevelOuter := bvNone;

L1 := TLabel.Create(WizardForm);
L1.Parent := WizardForm;
L1.Caption :=ExpandConstant('Параметры Установки');
L1.SetBounds(30,30,600,100);
L1.AutoSize:= false;
L1.Alignment := taCenter;
L1.Font.Size:=16;
L1.Font.Name := '{#FontName2}';
L1.Transparent:= True;

WizardForm.Bevel.SetBounds(0,355,660,1);

WizardForm.CancelButton.SetBounds(567,366,85,30);
WizardForm.CancelButton.Font.Size:=9;
WizardForm.CancelButton.Font.Name:='{#FontName}';

WizardForm.NextButton.SetBounds(567,366,85,30);
WizardForm.NextButton.Font.Size:=10;
WizardForm.NextButton.Font.Name:='{#FontName}';

ShowBtn := TNewButton.Create(WizardForm);
ShowBtn.Parent := WizardForm;
ShowBtn.SetBounds(8,366,60,30);
ShowBtn.Caption :=ExpandConstant('{cm:aboutbutton}');
ShowBtn.OnClick := @ActivateClick
ShowBtn.Font.Name:='{#FontName}';
ShowBtn.Font.Size:=10;
end;
p1 := TPanel.Create(WizardForm);
p1.Parent := WizardForm;
p1.SetBounds(10,92,642,136);
p1.BevelInner := bvSpace;
p1.BevelOuter := bvLowered;
p1.ParentBackground := False;
p1.Color := 13948116;

p2 := TPanel.Create(WizardForm);
p2.Parent := WizardForm;
p2.SetBounds(10,243,642,96);
p2.BevelInner := bvSpace;
p2.BevelOuter := bvLowered;
p2.ParentBackground := False;
p2.Color := 13948116;

p3 := TPanel.Create(WizardForm);
p3.Parent := WizardForm;
p3.SetBounds(10,159,642,180);
p3.BevelInner := bvSpace;
p3.BevelOuter := bvLowered;
p3.ParentBackground := False;
p3.Color := 13948116;

  StartButton := TNewButton.Create(WizardForm);
  with StartButton do
  begin
    Parent := WizardForm;
    Font.Name:='{#FontName}';
    Font.Size:=10;
    SetBounds(8,366,60,30);
    Caption:=ExpandConstant('{cm:StartButton}');
    OnClick:=@StartButtonClick;
  end;
//=-=-=-=-=-=-=-=-=-=-=-
  WelcomeLabel:= TLabel.Create(WizardForm);
  with WelcomeLabel do
  begin
    AutoSize:= false;
    Parent := WizardForm;
    Alignment := taCenter;
    Font.Size:=14;
    SetBounds(30,120,600,100);
    Caption :=ExpandConstant('{cm:WelcomeLabel}');
    Font.Name := '{#FontName}';
    Transparent:= True;
  end;

  WelcomeLabel1:= TLabel.Create(WizardForm);
  with WelcomeLabel1 do
  begin
    AutoSize:= false;
    Parent := WizardForm;
    Alignment := taCenter;
    Font.Size:=16;
    SetBounds(30,150,600,100);
    Caption := '{#AppName}';
    Font.Name := '{#FontName2}';
    Transparent:= True;
  end;

  WelcomeLabel2:= TLabel.Create(WizardForm);
  with WelcomeLabel2 do
  begin
    Parent := WizardForm;
    AutoSize:= false;
    Font.Name := '{#FontName}';
    Font.Size:=10;
    Alignment := taCenter;
    Transparent:= true;
    WordWrap:= true;
    Top :=WelcomeLabel1.Top+ScaleY(80);
    Left := ScaleX(30);
    Width := ScaleX(600);
    Height := ScaleX(200);
    Caption :=ExpandConstant('{cm:WelcomeLabel2}');
  end;
//=-=-=-=-=-=-=-=-=-=-=-
  Dirlabel:= TLabel.Create(WizardForm);
  with Dirlabel do
  begin
    Parent := p1;
    Left := ScaleY(8);
    Top := ScaleX(13);
    Font.Name := '{#FontName2}';
    Caption :=ExpandConstant('{cm:Dirlabel}');
    Transparent:= True;
  end;

  Dirlabel2:= TLabel.Create(WizardForm);
  with Dirlabel2 do
  begin
    Parent := p1;
    WordWrap := False;
    AutoSize := False;
    Left := ScaleY(480);
    Top := ScaleX(5);
    Width := ScaleX(156);
    Height := ScaleY(124);
    Font.Name := '{#FontName2}';
    Transparent:= True;
    Layout:=tlCenter;
  end;

  with WizardForm.DirEdit do
  begin
    Parent := p1;
    Top := ScaleY(40);
    Left := ScaleX(20);
    Width := ScaleX(360);
    Font.Name := '{#FontName2}';
    Font.Color := clGreen;
    OnChange:=@DirEditOnChange;
  end;

  with WizardForm.DirBrowseButton do
  begin
    Parent := p1;
    Top := WizardForm.DirEdit.Top+ScaleY(-1);
    Left := WizardForm.DirEdit.Width+WizardForm.DirEdit.Left+ScaleX(20);
    Width := ScaleX(72);
    Height := ScaleY(24);
    Font.Name := '{#FontName2}';
    //Font.Size:= {#FontButton};
  end;

  Grouplabel:= TLabel.Create(WizardForm);
  with Grouplabel do
  begin
    Parent := p1;
    Left := ScaleY(8);
    Top := WizardForm.DirEdit.Top+WizardForm.DirEdit.Height+ScaleY(12);
    Font.Name := '{#FontName2}';
    Caption :=ExpandConstant('{cm:Grouplabel}');
    Transparent:= True;
  end;

  with WizardForm.GroupEdit do
  begin
    Parent := p1;
    Top := WizardForm.DirEdit.Top+ScaleY(60);
    Left := ScaleX(20);
    Width := ScaleX(360);
    Font.Name := '{#FontName2}';
    Font.Color := clGreen;
  end;

  with WizardForm.GroupBrowseButton do
  begin
    Parent := p1;
    Top := WizardForm.GroupEdit.Top+ScaleY(-1);
    Left := WizardForm.GroupEdit.Width+WizardForm.GroupEdit.Left+ScaleX(20);
    Width := ScaleX(72);
    Height := ScaleY(24);
    Font.Name := '{#FontName2}';
//  Font.Size:= {#FontButton};
  end;

  Options := TNewButton.Create(WizardForm);
  with Options do
  begin
    Parent := WizardForm;
    Left := ScaleX(8);
    Top := ScaleY(366);
    Width := ScaleX(150);
    Height := ScaleY(30);
    Caption := 'Дополнительные настройки';
    OnClick := @OptionsClick;
  end;
  PanelOptions := TPanel.Create(WizardForm);
  with PanelOptions do
  begin
    Parent := WizardForm;
    Left := ScaleX(20);
    Top := ScaleY(250);
    Width := ScaleX(620);
    Height := ScaleY(80);
    Caption := '';
    BevelInner := bvSpace;
    BevelOuter := bvLowered;
    ParentBackground := False;
    Color := 13948116;
  end;
  Soft := TNewCheckBox.Create(WizardForm);
  with Soft do
  begin
    Parent := PanelOptions;
    Left := ScaleX(16);
    Top := ScaleY(16);
    Width := ScaleX(97);
    Height := ScaleY(17);
    Caption := 'Soft';
  end;

  { Desktop }
  Desktop := TNewCheckBox.Create(WizardForm);
  with Desktop do
  begin
    Parent := PanelOptions;
    Left := ScaleX(16);
    Top := ScaleY(40);
    Width := ScaleX(97);
    Height := ScaleY(17);
    Caption := 'Desktop';
end;
end;

//=-=-=-=-=-=-=-=-=-=-=-
procedure InitializeWizard;
begin

if not FontExists('{#FontName}') then
begin
ExtractTemporaryFile('{#Font}');
AddFontResource(ExpandConstant('{tmp}\{#Font}'), FR_PRIVATE, 0);
ExtractTemporaryFile('{#Font2}');
AddFontResource(ExpandConstant('{tmp}\{#Font2}'), FR_PRIVATE, 0);
end;
WizardForm.Font.Name := '{#FontName}';
with WizardForm do begin
Caption:='{#AppName}';
Color:=$00D3D3D3;
Position:=poScreenCenter;
InnerNotebook.Hide;
OuterNotebook.Hide;
ClientWidth:=660;
ClientHeight:=405;

//BorderStyle := bsDialog;
WZ();
  Win7TaskBar20();

end;
end;
//=-=-=-=-=-=-=-=-=-=-=-
procedure CurPageChanged(CurPageID: Integer);
begin

HideComponents;
Wizardform.NextButton.Enabled := False;
PanelOptions.Hide;
case CurPageID of
wpWelcome:
begin
WelcomeLabel.Show;
WelcomeLabel1.Show;
WelcomeLabel2.Show;
WizardForm.WizardBitmapImage2.Show;
WizardForm.NextButton.Caption:=ExpandConstant('{cm:NextButton}');
end;
wpSelectDir:
begin
p1.Show;
p2.Show;
WizardForm.WizardBitmapImage2.Hide;
WizardForm.NextButton.Caption:=ExpandConstant('{cm:NextButton}');

end;
wpInstalling:
begin
p3.Show;
L1.Show;
L1.SetBounds(30,100,600,100);
L1.Caption:=ExpandConstant('{cm:WelcomeLabel3}');
WizardForm.WizardBitmapImage2.Show;
WizardForm.CancelButton.Caption:=ExpandConstant('{cm:EndButton}');
end;

wpfinished:
begin
WelcomeLabel1.Show;
WelcomeLabel1.Caption:='{#AppName}';
WelcomeLabel2.Show;
WelcomeLabel2.Caption:=ExpandConstant('{cm:WelcomeLabel4}');
Wizardform.NextButton.Enabled := True;
WizardForm.NextButton.Caption:=ExpandConstant('{cm:FinButton}');
WizardForm.WizardBitmapImage2.Show;
StartButton.Show;
end;
end;
end;
//=-=-=-=-=-=-=-=-=-=-=-
function ShouldSkipPage(PageID: Integer): Boolean;
begin
if (PageID=6)or (PageID=7)or (PageID=8)or (PageID=10)
then Result:=true;
end;
//=-=-=-=-=-=-=-=-=-=-=-
procedure DeinitializeSetup;
begin
RemoveFontResource(ExpandConstant('{tmp}\{#Font}'), FR_PRIVATE, 0);
RemoveFontResource(ExpandConstant('{tmp}\{#Font2}'), FR_PRIVATE, 0);
WizardForm.Free;
end;
//=-=-=-=-=-=-=-=-=-=-=-[/SPOILER]

Почистил немного
 

Вложения

  • 2.5 MB Просмотры: 28
Последнее редактирование:

EvilAlex

Старожил
Видел пример с кнопками без ботвы, 4 состояния вроде... Помогите найти.
 

Вложения

  • 2.9 KB Просмотры: 16
Последнее редактирование:

Nemko

Дилетант
Модератор
EvilAlex, есть в справке (что с форума в CHM формате), в разделе "Inno Setup Faq. Текстурирование кнопок":
Код:
;;Скрипт текстурирования кнопок, с четырмя видами состояния кнопок
;;Используется текстура размером 320х23, где размер одной кнопки 80х23
;;Скрипт написал Shegorat
[Setup]
AppName=Test
AppVerName=Test
DefaultDirName={pf}\Test
OutputDir=userdocs:Test.

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

[Files]
;;Изображение размером 320х23
Source: button2.bmp; DestDir: {tmp}; Flags: dontcopy
[*Code]
const
ButtonWidth = 85;
ButtonHeight = 23;

var
WizardLabel: TLabel;
ButtonPanel: array of TPanel;
ButtonImage: array of TBitmapImage;
ButtonLabel: array of TLabel;
UsedButtons: array of TButton;
ButtonsCount: Integer;

procedure ButtonLabelClick(Sender: TObject);
var Button: TButton; n, i: Integer;
begin
i:= TLabel(Sender).Tag; ButtonImage[i].Left:= 0
for n:=0 to (ButtonsCount-1) do begin
if i = n then Button:= UsedButtons[n];
end;
Button.OnClick(Button)
end;

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

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

procedure ButtonLabelMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
var n, I: Integer;
begin
I:=TLabel(Sender).Tag;
///Сначала восстанавливаем картинку у всех кнопок, так надо иначе могут быть глюки
for n:=0 to (ButtonsCount-1) do begin if (ButtonLabel[n].Enabled)and(ButtonImage[n].Left <> -ButtonWidth*2)and(I<>N) then ButtonImage[n].Left:= 0; end;
///Теперь собственно ставим нужную картинку
if (ButtonLabel[I].Enabled)and(ButtonImage[I].Left <> -ButtonWidth*2) then begin ButtonImage[I].Left:= -ButtonWidth; end;
end;

procedure WizardLabelMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
var n: Integer;
begin
///Т.к Sender'ом выступает WizardLabel то не получится испльзовать индекс кнопки
for n:=0 to (ButtonsCount-1) do if (ButtonLabel[n].Enabled)and(ButtonImage[n].Left <> -ButtonWidth*2) then begin ButtonImage[n].Left:= 0; end;
end;

procedure LoadButtonImage(AButton: TButton);
var n: Integer;
begin
n:=ButtonsCount; SetArrayLength(ButtonPanel, n+1);
SetArrayLength(ButtonImage, n+1); SetArrayLength(ButtonLabel, n+1);
SetArrayLength(UsedButtons, n+1); UsedButtons[n]:= AButton;

ButtonPanel[n]:=TPanel.Create(WizardForm)
ButtonPanel[n].SetBounds(AButton.Left, AButton.Top, AButton.Width, AButton.Height)
ButtonPanel[n].Tag:= n
ButtonPanel[n].Enabled:= AButton.Enabled
ButtonPanel[n].Parent:=AButton.Parent

ButtonImage[n]:=TBitmapImage.Create(WizardForm)
ButtonImage[n].SetBounds(ScaleX(0), ScaleY(0), ScaleX(320), ScaleY(23))
ButtonImage[n].Enabled:=False
ButtonImage[n].Bitmap.LoadFromFile(ExpandConstant('{tmp}\Button2.bmp'))
ButtonImage[n].Parent:=ButtonPanel[n]

with TLabel.Create(WizardForm) do begin
Tag:=n
Parent:=ButtonPanel[n]
Width:=AButton.Width
Height:=AButton.Height
Transparent:=True
OnClick:=@ButtonLabelClick
OnDblClick:=@ButtonLabelClick
OnMouseMove:=@ButtonLabelMove
OnMouseDown:=@ButtonLabelMouseDown
OnMouseUp:=@ButtonLabelMouseUp
end;

ButtonLabel[n]:=TLabel.Create(WizardForm)
ButtonLabel[n].Autosize:=True
ButtonLabel[n].Alignment:=taCenter
ButtonLabel[n].Tag:=n
ButtonLabel[n].Enabled:= AButton.Enabled
ButtonLabel[n].Transparent:=True
ButtonLabel[n].Font.Color:=clWhite
ButtonLabel[n].Caption:=AButton.Caption
ButtonLabel[n].OnClick:=@ButtonLabelClick
ButtonLabel[n].OnDblClick:=@ButtonLabelClick
ButtonLabel[n].OnMouseMove:=@ButtonLabelMove
ButtonLabel[n].OnMouseDown:=@ButtonLabelMouseDown
ButtonLabel[n].OnMouseUp:=@ButtonLabelMouseUp
ButtonLabel[n].Parent:=ButtonPanel[n]

ButtonsCount:= ButtonsCount+1
end;

procedure UpdateButtons();
var n: Integer;
begin
for n:=0 to ButtonsCount-1 do begin
ButtonLabel[n].Caption:=UsedButtons[n].Caption
ButtonPanel[n].Visible:=UsedButtons[n].Visible
if (UsedButtons[n].Enabled = False) then ButtonImage[n].Left:= -ButtonWidth*3 else ButtonImage[n].Left:= 0;
ButtonLabel[n].Enabled:= UsedButtons[n].Enabled;
ButtonPanel[n].Enabled:= UsedButtons[n].Enabled;
///Ставим Left и Top лейбла соразмерно размеру лейбла
ButtonLabel[n].Left:= ButtonPanel[n].Width div 2 - ButtonLabel[n].Width div 2;
ButtonLabel[n].Top:= ButtonPanel[n].Height div 2 - ButtonLabel[n].Height div 2;
end;
end;

procedure LicenceAcceptedRadioOnClick(Sender: TObject);
begin
///Делаем кнопку активной
WizardForm.NextButton.Enabled:= True;
///Обновляем текстурированную кнопку (обновляем активность и текстуру)
UpdateButtons();
end;

procedure LicenceNotAcceptedRadioOnClick(Sender: TObject);
begin
///Делаем кнопку неактивной
WizardForm.NextButton.Enabled:= False;
///Обновляем текстурированную кнопку (обновляем активность и текстуру)
UpdateButtons()
end;

procedure InitializeWizard();
begin
WizardLabel:= TLabel.Create(WizardForm)
WizardLabel.SetBounds(ScaleX(0), ScaleY(0), ScaleX(WizardForm.Width), ScaleY(WizardForm.Height))
WizardLabel.Transparent:= True;
WizardLabel.AutoSize:=false;
WizardLabel.OnMouseMove:=@WizardLabelMove
WizardLabel.Parent:= WizardForm;

WizardForm.BackButton.Width:= ButtonWidth
WizardForm.BackButton.Height:= ButtonHeight

WizardForm.NextButton.Width:= ButtonWidth
WizardForm.NextButton.Height:= ButtonHeight

WizardForm.CancelButton.Width:=ButtonWidth
WizardForm.CancelButton.Height:= ButtonHeight

WizardForm.DirBrowseButton.Left:=ScaleX(337)
WizardForm.DirBrowseButton.Width:= ButtonWidth
WizardForm.DirBrowseButton.Height:=ButtonHeight

WizardForm.GroupBrowseButton.Left:=ScaleX(337)
WizardForm.GroupBrowseButton.Width:= ButtonWidth
WizardForm.GroupBrowseButton.Height:=ButtonHeight

WizardForm.LicenseAcceptedRadio.OnClick:=@LicenceAcceptedRadioOnClick

WizardForm.LicenseNotAcceptedRadio.OnClick:=@LicenceNotAcceptedRadioOnClick

ExtractTemporaryFile('button2.bmp')
LoadButtonImage(WizardForm.BackButton)
LoadButtonImage(WizardForm.NextButton)
LoadButtonImage(WizardForm.CancelButton)
LoadButtonImage(WizardForm.DirBrowseButton)
LoadButtonImage(WizardForm.GroupBrowseButton)
end;

procedure CurPageChanged(CurPageID: Integer);
begin
UpdateButtons()
end;
 

EvilAlex

Старожил
@Nemko, а как мне новую кнопку добавить в этот скрипт чтоб на ней тоже накладывались текстуры ?
Код:
Options := TNewButton.Create(WizardForm);
  with Options do
  begin
    Parent := WizardForm;
    Left := ScaleX(8);
    Top := ScaleY(370);
    Width := ScaleX(85);
    Height := ScaleY(28);
    Caption := 'Опции';
    OnClick := @OptionsClick;
  end;
 
Последнее редактирование:

Nemko

Дилетант
Модератор
EvilAlex, вроде того:
Код:
[Setup]
AppName=Test
AppVerName=Test
CreateAppDir=no

[Files]
;;Изображение размером 320х23
Source: button2.bmp; DestDir: {tmp}; Flags: dontcopy

[*Code]
const
  ButtonWidth = 85;
  ButtonHeight = 23;

var
  WizardLabel: TLabel;
  ButtonPanel: array of TPanel;
  ButtonImage: array of TBitmapImage;
  ButtonLabel: array of TLabel;
  UsedButtons: array of TButton;
  ButtonsCount: Integer;

procedure ButtonLabelClick(Sender: TObject);
var
  n, i: Integer;
begin
  i:=TLabel(Sender).Tag;
  ButtonImage[i].Left:=0;
  for n:=0 to (ButtonsCount-1) do if i = n then UsedButtons[n].OnClick(UsedButtons[n]);
end;

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

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

procedure ButtonLabelMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
var
  n, I: Integer;
begin
  I:=TLabel(Sender).Tag;
  for n:=0 to (ButtonsCount-1) do begin
    if (ButtonLabel[n].Enabled) and (ButtonImage[n].Left <> -ButtonWidth*2)and(I<>N) then ButtonImage[n].Left:= 0;
  end;
  if (ButtonLabel[I].Enabled) and (ButtonImage[I].Left <> -ButtonWidth*2) then begin
    ButtonImage[I].Left:= -ButtonWidth;
  end;
end;

procedure WizardLabelMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
var
  n: Integer;
begin
  for n:=0 to (ButtonsCount-1) do if (ButtonLabel[n].Enabled) and (ButtonImage[n].Left <> -ButtonWidth*2) then begin
    ButtonImage[n].Left:= 0;
  end;
end;

procedure LoadButtonImage(AButton: TButton);
var
  n: Integer;
begin
  n:=ButtonsCount;
  SetArrayLength(ButtonPanel, n+1);
  SetArrayLength(ButtonImage, n+1);
  SetArrayLength(ButtonLabel, n+1);
  SetArrayLength(UsedButtons, n+1);
  UsedButtons[n]:=AButton;
 
  ButtonPanel[n]:=TPanel.Create(WizardForm);
  with ButtonPanel[n] do begin
    SetBounds(AButton.Left, AButton.Top, AButton.Width, AButton.Height);
    Tag:=n;
    Enabled:=AButton.Enabled;
    Parent:=AButton.Parent;
  end;
 
  ButtonImage[n]:=TBitmapImage.Create(WizardForm);
  with ButtonImage[n] do begin
    SetBounds(ScaleX(0), ScaleY(0), ScaleX(320), ScaleY(23));
    Enabled:=False;
    Bitmap.LoadFromFile(ExpandConstant('{tmp}\Button2.bmp'));
    Parent:=ButtonPanel[n];
  end;
 
  with TLabel.Create(WizardForm) do begin
    Tag:=n;
    Parent:=ButtonPanel[n]
    Width:=AButton.Width;
    Height:=AButton.Height;
    Transparent:=True;
    OnClick:=@ButtonLabelClick;
    OnDblClick:=@ButtonLabelClick;
    OnMouseMove:=@ButtonLabelMove;
    OnMouseDown:=@ButtonLabelMouseDown;
    OnMouseUp:=@ButtonLabelMouseUp;
  end;

  ButtonLabel[n]:=TLabel.Create(WizardForm);
  with ButtonLabel[n] do begin
    Autosize:=True;
    Alignment:=taCenter;
    Tag:=n;
    Enabled:= AButton.Enabled;
    Transparent:=True;
    Font.Color:=clWhite;
    Caption:=AButton.Caption;
    OnClick:=@ButtonLabelClick;
    OnDblClick:=@ButtonLabelClick;
    OnMouseMove:=@ButtonLabelMove;
    OnMouseDown:=@ButtonLabelMouseDown;
    OnMouseUp:=@ButtonLabelMouseUp;
    Parent:=ButtonPanel[n];
  end;
  ButtonsCount:=ButtonsCount+1;
end;

procedure UpdateButtons;
var
  n: Integer;
begin
  for n:=0 to ButtonsCount-1 do begin
    ButtonLabel[n].Caption:=UsedButtons[n].Caption
    ButtonPanel[n].Visible:=UsedButtons[n].Visible
    if (UsedButtons[n].Enabled = False) then ButtonImage[n].Left:= -ButtonWidth*3 else ButtonImage[n].Left:= 0;
    ButtonLabel[n].Enabled:= UsedButtons[n].Enabled;
    ButtonPanel[n].Enabled:= UsedButtons[n].Enabled;
    ButtonLabel[n].Left:= ButtonPanel[n].Width div 2 - ButtonLabel[n].Width div 2;
    ButtonLabel[n].Top:= ButtonPanel[n].Height div 2 - ButtonLabel[n].Height div 2;
  end;
end;

procedure LicenceAcceptedRadioOnClick(Sender: TObject);
begin
  WizardForm.NextButton.Enabled:=True;
  UpdateButtons;
end;

procedure LicenceNotAcceptedRadioOnClick(Sender: TObject);
begin
  WizardForm.NextButton.Enabled:=False;
  UpdateButtons;
end;

//========================================
var
  MyButton: TButton;

procedure MyButtonClick(Sender: TObject);
begin
  Beep;
end;
//========================================

procedure InitializeWizard;
begin
  WizardLabel:= TLabel.Create(WizardForm);
  WizardLabel.SetBounds(ScaleX(0), ScaleY(0), ScaleX(WizardForm.Width), ScaleY(WizardForm.Height));
  WizardLabel.Transparent:=True;
  WizardLabel.AutoSize:=false;
  WizardLabel.OnMouseMove:=@WizardLabelMove;
  WizardLabel.Parent:= WizardForm;

  WizardForm.BackButton.Width:= ButtonWidth;
  WizardForm.BackButton.Height:= ButtonHeight;

  WizardForm.NextButton.Width:= ButtonWidth;
  WizardForm.NextButton.Height:= ButtonHeight;

  WizardForm.CancelButton.Width:=ButtonWidth;
  WizardForm.CancelButton.Height:= ButtonHeight;

  WizardForm.DirBrowseButton.Left:=ScaleX(337);
  WizardForm.DirBrowseButton.Width:=ButtonWidth;
  WizardForm.DirBrowseButton.Height:=ButtonHeight;

  WizardForm.GroupBrowseButton.Left:=ScaleX(337);
  WizardForm.GroupBrowseButton.Width:= ButtonWidth;
  WizardForm.GroupBrowseButton.Height:=ButtonHeight;

  WizardForm.LicenseAcceptedRadio.OnClick:=@LicenceAcceptedRadioOnClick;
  WizardForm.LicenseNotAcceptedRadio.OnClick:=@LicenceNotAcceptedRadioOnClick;

  //========================================
  MyButton:=TButton.Create(WizardForm);
  with MyButton do begin
    SetBounds(ScaleX(10), ScaleY(WizardForm.NextButton.Top), ScaleX(ButtonWidth), ScaleY(ButtonHeight));
    Caption:=SetupMessage(msgAboutSetupTitle);
    OnClick:=@MyButtonClick;
    Parent:=WizardForm;
  end;
  //========================================
  ExtractTemporaryFile('button2.bmp');
  LoadButtonImage(WizardForm.BackButton);
  LoadButtonImage(WizardForm.NextButton);
  LoadButtonImage(WizardForm.CancelButton);
  LoadButtonImage(WizardForm.DirBrowseButton);
  LoadButtonImage(WizardForm.GroupBrowseButton);
  //========================================
  LoadButtonImage(MyButton);
  //========================================
end;

procedure CurPageChanged(CurPageID: Integer);
begin
  UpdateButtons;
end;
 
Сверху