Benjamin Close
Benjamin Close

Reputation: 331

How to add a new page to Inno Setup OuterNotebook?

As part of an installer I'm working on using Inno Setup, I need to replicate the wpWelcome, page but with a different content. I've created a TNotebookPage, added the image, panel and content I want and it displays as expected. However I'm not sure how to add it to the WizardForm at the location I want. I can force it to appear as the first page, but clicking next/back shifts make the page disappear.

How do I insert the notebook page into the OuterNotebook at the relevant position?

function CreatePage: TNewNoteBookPage;
var
  page: TNewNoteBookPage;
begin 
  page := TNewNoteBookPage.Create( WizardForm );
  page.Notebook := WizardForm.OuterNotebook;
  page.Align := alClient;
  page.Color := clWindow;
  page.Visible:= True;

  Result := page;
end;

procedure InitializeWizard;
var
  myPage: TNewNoteBookPage;
begin
  WizardForm.OuterNotebook.ActivePage := WizardForm.WelcomePage;
  myPage := CreatePage();

  { how do I specify where I want the page in the OuterNotebook? }
end;

Upvotes: 2

Views: 718

Answers (2)

Benjamin Close
Benjamin Close

Reputation: 331

Martin's suggestions were very helpful, whilst not solving the problem directly they gave me an idea. I needed more than just a image covering the window. Hence my solution was to create a TNoteBookPage which I could format as needed and also a TWizardPage. Since the notebookpage couldn't be added to the installer without breaking inno-setup's ordering, I used the custom page to maintain ordering and when the CustomPage was set active, I switch the active page to be the notebook page hence showing what I needed.

[Code]
Apage, TWizardPage;
ANotebookPage: TNewNoteBookPage;

function CreatePage: TNewNoteBookPage;
var
  page: TNewNoteBookPage;
  sideBarImage: TBitmapImage;
  panel: TPanel;
begin 

  {create page, sidebar and panel for our main content}
  page := TNewNoteBookPage.Create( WizardForm );
  page.Notebook := WizardForm.OuterNotebook;
  page.Align := alClient;
  page.Color := clWindow;
  page.Visible:= True;

  { copies the already loaded sidebar image on the welcome page to this notebook page}
  sideBarImage := TBitmapImage.Create( WizardForm );
  sideBarImage.Bitmap := WizardForm.WizardBitmapImage.Bitmap;       
  sideBarImage.Top := WizardForm.WizardBitmapImage.Top;
  sideBarImage.Left := WizardForm.WizardBitmapImage.Left;
  sideBarImage.Width := WizardForm.WizardBitmapImage.Width;
  sideBarImage.Height := WizardForm.WizardBitmapImage.Height;
  sideBarImage.BackColor := WizardForm.WizardBitmapImage.BackColor;
  sideBarImage.Parent := page;

  panel := TPanel.Create( WizardForm );
  panel.BevelOuter := bvNone;
  panel.Color  := clWindow;
  panel.Parent := page;
  panel.Left   := sideBarImage.Width + ScaleX(10);
  panel.Height := page.Height;
  panel.Width  := page.Width - sideBarImage.Width;

  { at this point we have a panel we can populate with content }

  Result := page
end

procedure InitializeWizard;
begin
  ANotebookPage := CreateOneClickInstallPage();
  APage := CreateCustomPage( wpLicense, 'Install', '');
end

procedure CurPageChanged( CurPageID: Integer );
begin
  WizardForm.Bevel1.Visible := true;
  WizardForm.MainPanel.Visible := true;
  WizardForm.InnerNotebook.Visible := true;

  if CurPageID = APage.ID then begin
    WizardForm.NextButton.Caption := SetupMessage(msgButtonInstall)  
    WizardForm.Bevel1.Visible := false;
    WizardForm.MainPanel.Visible := false;
    WizardForm.InnerNotebook.Visible := false;
    WizardForm.OuterNotebook.ActivePage := ANoteBookPage;
  end;
end

Upvotes: 1

Martin Prikryl
Martin Prikryl

Reputation: 202158

In general, you specify a page position using TNewNotebookPage.PageIndex. But I'm afraid that by "manually" modifying the OuterNotebook you break an inner Inno Setup logic.


Why don't you just modify the existing Welcome page, instead of creating a new one?

See, for example, Custom Welcome and Finished page with stretched image in Inno Setup.


Alternatively, create a custom page on the InnerNotebook, but expand it to cover a whole window.

See How to hide the main panel and show an image over the whole page?

Upvotes: 2

Related Questions