4

I'm looking for a way to create a one page installer in Inno Setup, just look at this screenshot: One Page Installer Image

Can anyone please give me the codes for doing this?

Or totally I would like to merge pages abilities in Inno Setup. For example merge Select directory page with Components page and etc

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
Inside Man
  • 4,194
  • 12
  • 59
  • 119
  • See also [Inno Setup - Folder to install the software, start menu folder, desktop icon all in the same page](https://stackoverflow.com/q/41076777/850848). – Martin Prikryl Oct 19 '20 at 06:28

1 Answers1

4

It's not easy to do by default. But it can be done, the following code produced a page like this one.enter image description here

[Setup]
AppName=Test
AppVersion=1.5
DefaultDirName={code:AppDir}
;Disable all of the default wizard pages
DisableDirPage=yes
DisableProgramGroupPage=yes
DisableReadyMemo=yes
DisableReadyPage=yes
DisableStartupPrompt=yes
DisableWelcomePage=yes

;May want this, after install.
DisableFinishedPage=no

[Messages]
ButtonNext=Install

[Files]
Source:"e:\test.txt"; DestDir: "{app}"
Source:"e:\test.txt"; DestDir: "{app}"; DestName: "test1.txt"; Check: Option1;
Source:"e:\test.txt"; DestDir: "{app}"; DestName: "test2.txt"; Check: Option2;


[Code]

var
 MainPage : TWizardPage;
 edtFolderToInstall : TEdit;
 InstallLocation : String;
 Opt1, Opt2 : Boolean;
 ChkOption1 :  TCheckBox;
 ChkOption2 :  TCheckBox;


function  AppDir(Param: String): String;
begin
  // Set Default if not set.
  if InstallLocation = '' then
     InstallLocation := ExpandConstant('{pf}') + 'test';
  result := InstallLocation;
end;

function Option1 : Boolean;
begin
  result := Opt1;
end;

function Option2 : Boolean;
begin
  result := Opt2;
end;

procedure BrowseClick(Sender : TObject);
var
 Dir : String;
begin
  Dir := edtFolderToInstall.Text;
  if BrowseForFolder('Select Folder',Dir,false) then
    edtFolderToInstall.Text := Dir;
end;

procedure InitializeWizard();
var
 lblFolderToInstall : TLabel;
 btnFolderToInstall : TButton;


begin
 MainPage := CreateCustomPage(wpWelcome,'Setup - Test App Name','This will install "Test App Name" to your computer');
 lblFolderToInstall := TLabel.Create(MainPage);
 lblFolderToInstall.Parent := MainPage.Surface;
 lblFolderToInstall.Top := 10;
 lblFolderToInstall.Left := 10;
 lblFolderToInstall.Caption := 'If you would like to select a different folder, Click Browse.'


 edtFolderToInstall := TEdit.Create(MainPage);
 edtFolderToInstall.Parent := MainPage.Surface;

 edtFolderToInstall.Top := 25;
 edtFolderToInstall.Left := 10;
 edtFolderToInstall.Width := 250;
 edtFolderToInstall.Text :=  WizardDirValue;


 btnFolderToInstall := TButton.Create(MainPage);
 btnFolderToInstall.Parent := MainPage.Surface;
 btnFolderToInstall.top := 25;
 btnFolderToInstall.Left := 275;
 btnfolderToInstall.Caption := 'Browse...';
 btnFolderToInstall.OnClick := @BrowseClick;

 ChkOption1 :=  TCheckBox.Create(MainForm);
 ChkOption1.Parent := MainPage.Surface;
 ChkOption1.Top := 50;
 ChkOption1.Left := 10;
 ChkOption1.Caption := 'Option 1';

 ChkOption2 :=  TCheckBox.Create(MainForm);
 ChkOption2.Parent := MainPage.Surface;
 ChkOption2.Top := 75;
 ChkOption2.Left := 10;
 ChkOption2.Caption := 'Option 2';



end;


function NextButtonClick(CurPageID: Integer): Boolean;
begin
  result := True;
  // Next pressed, better make sure selected items are correct.
  if CurPageId = MainPage.ID then
  begin
     InstallLocation := edtFolderToInstall.Text;
     Opt1 := ChkOption1.Checked;
     Opt2 := ChkOption2.Checked;
  end;
end;

To pull this off, I use {code:AppDir} as the default directory. This tells InnoSetup to use the function AppDir to retrieve the installation directory. I then can set it using my custom dialog.

Instead of using [Components] and/or [Tasks] I have to use Check in the [Files] Section.

Robert Love
  • 12,447
  • 2
  • 48
  • 80
  • Thanks for your reply, But it is too hard to do because it is too long! And of course there is no wizard image. I just want to do this: Adding "Desktop Shortcut" and "Start Menu Shortcut" check boxes to DirPage. If you can give the codes for it I'll apprecaite you a lot Robert :) Awaiting your Code :)) – Inside Man Jun 02 '11 at 15:15
  • I have shown you how it can be accomplished. I am not going to write it for you. – Robert Love Jun 02 '11 at 15:24
  • The Image can be added by creating a TBitmapImage Control. – Robert Love Jun 02 '11 at 15:25
  • OK, Thank you very very much, really great. I respect your job and time Robert ;) Thanks Again :) – Inside Man Jun 02 '11 at 16:33