我將嘗試使用此代碼來創建自定義表單,讓我找到文件解壓縮:Inno Setup - 如何創建自定義窗體,以便我可以找到要解壓縮的文件?
var
TNewDiskForm :TSetupForm;
DiskBitmapImage: TBitmapImage;
SelectDiskLabel,PathLabel: TLabel;
PathEdit: TEdit;
BrowseButton: TButton;
OKButton: TButton;
CancelButton: TButton;
Filename: String;
Path: String;
Dir: String;
ModalResult: Longint;
//Пути поиска файла
function GetSanitizedPath: String;
begin
Result := Trim(PathEdit.Text);
end;
procedure CancelButtonClick(CurPageID: Integer; var Cancel, Confirm: Boolean);
begin
Cancel :=True;
Confirm :=False;
end;
//Кнопки Обзор
procedure BrowseButtonClick(Sender: TObject);
begin
Dir := GetSanitizedPath;
if BrowseForFolder(SetupMessage (msgSelectDirectoryLabel), Dir, False) then
PathEdit.Text := Dir + '\';
TNewDiskForm.Show;
end;
// Форма зыкрытия (работает mrOK)
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
Path := PathEdit.Text;
Filename:= ExpandConstant ('data.bin');
case TNewDiskForm.ModalResult of
mrOK:
begin
if (Path = '') or not FileExists(Path + Filename) then
begin
CanClose := false
MsgBox(FmtMessage(SetupMessage(msgFileNotInDir2), [Filename, Path]), mbError, MB_OK);
end;
end;
mrCancel:
begin
CanClose := True;
end;
end;
end;
// запрос диска
procedure SelectDisk(const DiskNumber: Integer; const Filename, Path: String);
var
ExitFlag:Boolean;
begin
repeat
TNewDiskForm:= CreateCustomForm();
TNewDiskForm.SetBounds(ScaleX(0), ScaleY(0), ScaleX(377), ScaleY(200));
TNewDiskForm.CenterInsideControl(WizardForm, False);
TNewDiskForm.Caption:=SetupMessage(msgChangeDiskTitle);
TNewDiskForm.Font.Color:= clWindowText
TNewDiskForm.Font.Height:= -11
TNewDiskForm.Font.Name:= 'MS Sans Serif'
TNewDiskForm.Font.Style:= []
TNewDiskForm.OnCloseQuery:[email protected];
SelectDiskLabel:=TLabel.Create(TNewDiskForm)
SelectDiskLabel.SetBounds(ScaleX(72),ScaleY(8), ScaleX(297), ScaleY(72));
SelectDiskLabel.AutoSize:=False
SelectDiskLabel.WordWrap:=True
SelectDiskLabel.Transparent:=True
SelectDiskLabel.Font.Color:=clBlack
SelectDiskLabel.Font.Size:=8
SelectDiskLabel.Caption:=FmtMessage(SetupMessage(msgSelectDiskLabel2), [IntToStr(DiskNumber)]);
SelectDiskLabel.Parent:=TNewDiskForm
SelectDiskLabel.ShowAccelChar:= False
PathEdit:=TEdit.Create(TNewDiskForm)
PathEdit.SetBounds(ScaleX(8), ScaleY(96), ScaleX(281), ScaleY(21));
PathEdit.TabOrder:=2
PathEdit.Text := ExpandConstant('{src}\');
PathEdit.Parent := TNewDiskForm;
PathLabel:= TLabel.Create(TNewDiskForm);
PathLabel.SetBounds(ScaleX(8),ScaleY(80), ScaleX(5), ScaleY(14));
PathLabel.Font.Color:=clBlack
PathLabel.FocusControl:= PathEdit
PathLabel.Caption := SetupMessage(msgPathLabel);
PathLabel.Parent:=TNewDiskForm
BrowseButton := TNewButton.Create(TNewDiskForm);
BrowseButton.SetBounds(ScaleX(296), ScaleY(95), ScaleX(73), ScaleY(23));
BrowseButton.Parent := TNewDiskForm;
BrowseButton.OnClick:[email protected];
BrowseButton.Caption := SetupMessage(msgButtonBrowse);
CancelButton := TNewButton.Create(TNewDiskForm);
CancelButton.SetBounds(ScaleX(296), ScaleY(137), ScaleX(73), ScaleY(23));
CancelButton.ModalResult := mrCancel;
CancelButton.Parent := TNewDiskForm;
CancelButton.Caption := SetupMessage (msgButtonCancel);
OkButton := TNewButton.Create(TNewDiskForm);
OkButton.SetBounds(ScaleX(216), ScaleY(137), ScaleX(73), ScaleY(23));
OkButton.ModalResult := mrOk;
OkButton.Parent := TNewDiskForm;
OKButton.Caption := SetupMessage(msgButtonOK);
TNewDiskForm.ShowModal;
//закрытие формы (работает mrCancel)
case TNewDiskForm.ModalResult of
mrCancel:
begin
TNewDiskForm.Free;
ExitFlag := ExitSetupMsgBox;
case ExitFlag of
True: WizardForm.Close;
False: SelectDisk (DiskNumber,Filename,Path);
True: TNewDiskForm.free;
end;
end;
end;
until ((TNewDiskForm.ModalResult=mrOk) or (TNewDiskForm.ModalResult = mrCancel));
end;
procedure CurStepChanged(CurStep: TSetupStep);
begin
// Запуск формы распаковки № диска место поиска
// | |
if not (FileExists('data.bin')) then
if CurStep = ssInstall then SelectDisk (2, 'Filename','{src}');
end;
此代碼工作正常(僅當該文件不存在開始,如果我表示它在哪裏,過程在繼續)在舊版本的inno setup(俄語版本)中,但我試圖修改以處理inno setup的最後一個版本(未知標識符「MODALRESULT」)。
1)如何修改代碼以使用最新版本的inno setup?
2)如何同時檢查多個文件? (文件名,文件名等)
你試過了什麼?爲什麼定製表單?基於'TInputDirWizardPage'的自定義頁面將更容易實現。 –
請參閱https://stackoverflow.com/q/12951327/850848 + *「安裝程序不會繼續」* =>我沒有看到,爲什麼它不應該。它有什麼作用? –
[mcve],請! –