How to add a new page to Inno Setup OuterNotebook?

安稳与你 提交于 2021-01-24 07:56:02

问题


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;

回答1:


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?




回答2:


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


来源:https://stackoverflow.com/questions/47521142/how-to-add-a-new-page-to-inno-setup-outernotebook

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!