2024-08-03 20:33:25 +02:00
|
|
|
unit Setup.NewDiskForm;
|
2011-10-06 20:53:09 +02:00
|
|
|
|
|
|
|
{
|
|
|
|
Inno Setup
|
2025-01-11 04:49:38 -06:00
|
|
|
Copyright (C) 1997-2025 Jordan Russell
|
2011-10-06 20:53:09 +02:00
|
|
|
Portions by Martijn Laan
|
|
|
|
For conditions of distribution and use, see LICENSE.TXT.
|
|
|
|
|
|
|
|
New Disk form
|
|
|
|
}
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
uses
|
|
|
|
Windows, SysUtils, Messages, Classes, Graphics, Controls, Forms, Dialogs,
|
2024-08-03 17:15:13 +02:00
|
|
|
Setup.SetupForm, StdCtrls, ExtCtrls, NewStaticText, BitmapImage, BidiCtrls;
|
2011-10-06 20:53:09 +02:00
|
|
|
|
|
|
|
type
|
|
|
|
TNewDiskForm = class(TSetupForm)
|
|
|
|
DiskBitmapImage: TBitmapImage;
|
|
|
|
SelectDiskLabel: TNewStaticText;
|
|
|
|
PathLabel: TNewStaticText;
|
|
|
|
PathEdit: TEdit;
|
|
|
|
BrowseButton: TNewButton;
|
|
|
|
OKButton: TNewButton;
|
|
|
|
CancelButton: TNewButton;
|
|
|
|
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
|
|
|
|
procedure BrowseButtonClick(Sender: TObject);
|
|
|
|
private
|
|
|
|
{ Private declarations }
|
|
|
|
Filename: string;
|
|
|
|
function GetSanitizedPath: String;
|
2024-12-26 02:29:51 -06:00
|
|
|
procedure CMShowingChanged(var Message: TMessage); message CM_SHOWINGCHANGED;
|
2011-10-06 20:53:09 +02:00
|
|
|
public
|
|
|
|
{ Public declarations }
|
|
|
|
constructor Create(AOwner: TComponent); override;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function SelectDisk(const DiskNumber: Integer; const AFilename: String; var Path: String): Boolean;
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
|
|
uses
|
2024-08-06 13:54:25 +02:00
|
|
|
SetupLdrAndSetup.Messages, Shared.SetupMessageIDs, PathFunc, Shared.CommonFunc.Vcl, Shared.CommonFunc, BrowseFunc,
|
2024-12-12 03:51:21 -06:00
|
|
|
Setup.MainFunc, Setup.MainForm, Setup.WizardForm;
|
2011-10-06 20:53:09 +02:00
|
|
|
|
|
|
|
{$R *.DFM}
|
|
|
|
|
|
|
|
function SelectDisk(const DiskNumber: Integer; const AFilename: String;
|
|
|
|
var Path: String): Boolean;
|
|
|
|
begin
|
2024-12-26 02:29:51 -06:00
|
|
|
Application.Restore; { see comments in AppMessageBox }
|
2024-12-12 03:51:21 -06:00
|
|
|
|
2011-10-06 20:53:09 +02:00
|
|
|
with TNewDiskForm.Create(Application) do
|
|
|
|
try
|
|
|
|
Filename := AFilename;
|
|
|
|
SelectDiskLabel.Caption := FmtSetupMessage(msgSelectDiskLabel2, [IntToStr(DiskNumber)]);
|
|
|
|
PathEdit.Text := Path;
|
2024-12-25 01:58:18 -06:00
|
|
|
ActiveControl := OKButton;
|
2011-10-06 20:53:09 +02:00
|
|
|
Result := ShowModal = mrOK;
|
|
|
|
if Result then
|
|
|
|
Path := GetSanitizedPath;
|
|
|
|
finally
|
|
|
|
Free;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
{ TNewDiskForm }
|
|
|
|
|
|
|
|
constructor TNewDiskForm.Create(AOwner: TComponent);
|
|
|
|
begin
|
|
|
|
inherited;
|
|
|
|
|
|
|
|
InitializeFont;
|
|
|
|
|
|
|
|
Caption := SetupMessages[msgChangeDiskTitle];
|
|
|
|
PathLabel.Caption := SetupMessages[msgPathLabel];
|
|
|
|
BrowseButton.Caption := SetupMessages[msgButtonBrowse];
|
|
|
|
OKButton.Caption := SetupMessages[msgButtonOK];
|
|
|
|
CancelButton.Caption := SetupMessages[msgButtonCancel];
|
|
|
|
|
2021-04-16 20:30:52 +02:00
|
|
|
DiskBitmapImage.InitializeFromIcon(HInstance, 'Z_DISKICON', Color, [48, 64]); {don't localize}
|
2011-10-06 20:53:09 +02:00
|
|
|
|
|
|
|
TryEnableAutoCompleteFileSystem(PathEdit.Handle);
|
2019-01-05 13:25:04 +01:00
|
|
|
|
|
|
|
KeepSizeY := True;
|
|
|
|
{ WizardForm will not exist yet if we're being called from [Code]'s
|
|
|
|
ExtractTemporaryFile in InitializeSetup }
|
|
|
|
FlipSizeAndCenterIfNeeded(Assigned(WizardForm), WizardForm, False);
|
2011-10-06 20:53:09 +02:00
|
|
|
end;
|
|
|
|
|
2024-12-26 02:29:51 -06:00
|
|
|
procedure TNewDiskForm.CMShowingChanged(var Message: TMessage);
|
|
|
|
begin
|
|
|
|
inherited;
|
|
|
|
{ This usually just makes the taskbar button flash }
|
|
|
|
if Showing then
|
|
|
|
SetForegroundWindow(Handle);
|
2024-12-25 01:40:53 -06:00
|
|
|
end;
|
|
|
|
|
2011-10-06 20:53:09 +02:00
|
|
|
function TNewDiskForm.GetSanitizedPath: String;
|
|
|
|
begin
|
|
|
|
Result := PathExpand(RemoveBackslashUnlessRoot(Trim(PathEdit.Text)));
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TNewDiskForm.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
|
|
|
|
var
|
|
|
|
Path: String;
|
|
|
|
begin
|
|
|
|
case ModalResult of
|
|
|
|
mrOK: begin
|
|
|
|
Path := GetSanitizedPath;
|
|
|
|
if (Path = '') or not NewFileExists(AddBackslash(Path) + Filename) then begin
|
|
|
|
CanClose := False;
|
|
|
|
LoggedMsgBox(FmtSetupMessage(msgFileNotInDir2, [Filename, Path]),
|
|
|
|
'', mbError, MB_OK, False, 0);
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
mrCancel: CanClose := ExitSetupMsgBox;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TNewDiskForm.BrowseButtonClick(Sender: TObject);
|
|
|
|
var
|
|
|
|
Dir: String;
|
|
|
|
begin
|
|
|
|
Dir := GetSanitizedPath;
|
|
|
|
if BrowseForFolder(SetupMessages[msgSelectDirectoryLabel], Dir, Handle, False) then
|
|
|
|
PathEdit.Text := Dir;
|
|
|
|
end;
|
|
|
|
|
|
|
|
end.
|