Codename K
Codename K

Reputation: 744

Can you create a custom page that looks like the Finish page?

Can you create a custom page that looks like the Finish page?

This is the code for custom page,

UserPage2 := CreateCustomPage(
  UserPage1.ID,
  'Title',    
  'Details'
); 

This custom page,

enter image description here

Needs to look like this,

enter image description here

The reason for this is because, sometimes when the user runs the installer again they will be able to select few options. Based on the options the installer needs to make few changes to the settings used by the installed program without overwriting the files by reinstalling. So the user should get the Finish dialog after the changes.

Upvotes: 1

Views: 687

Answers (1)

Martin Prikryl
Martin Prikryl

Reputation: 202138

  1. Recreate the FinishedPage controls on your custom page.

  2. When entering the page, you need to resize WizardForm.InnerNotebook to cover whole wizard window (except for the bottom button area) and hide the page header controls.

var
  FakeFinishedPage: TWizardPage;
  FakeFinishedBitmapImage: TBitmapImage;
  FakeFinishedLabel: TNewStaticText;
  FakeFinishedHeadingLabel: TNewStaticText;

procedure CopyBounds(Dest, Source: TControl);
begin
  Dest.Left := Source.Left;
  Dest.Top := Source.Top;
  Dest.Width := Source.Width;
  Dest.Height := Source.Height;
end;

procedure FakeFinishedPageActivate(Sender: TWizardPage);
begin
  WizardForm.Bevel1.Visible := False;
  WizardForm.MainPanel.Visible := False;
  WizardForm.InnerNotebook.Left := 0;
  WizardForm.InnerNotebook.Top := 0;
  WizardForm.InnerNotebook.Width := WizardForm.OuterNotebook.ClientWidth;
  WizardForm.InnerNotebook.Height := WizardForm.OuterNotebook.ClientHeight;

  // With WizardStyle=modern and/or WizardResizable=yes,
  // we cannot copy the sizes in InitializeWizard as they are not final yet.
  CopyBounds(FakeFinishedBitmapImage, WizardForm.WizardBitmapImage2);
  FakeFinishedBitmapImage.Anchors := WizardForm.WizardBitmapImage2.Anchors;

  CopyBounds(FakeFinishedLabel, WizardForm.FinishedLabel);
  FakeFinishedLabel.Anchors := WizardForm.FinishedLabel.Anchors;
  CopyBounds(FakeFinishedHeadingLabel, WizardForm.FinishedHeadingLabel);
  FakeFinishedHeadingLabel.Anchors := WizardForm.FinishedHeadingLabel.Anchors;

  WizardForm.BackButton.Visible := False;
  WizardForm.NextButton.Caption := SetupMessage(msgButtonFinish);
end;

procedure CopyLabel(Dest, Source: TNewStaticText);
begin
  Dest.AutoSize := Source.AutoSize;
  Dest.Font := Source.Font;
  Dest.ShowAccelChar := Source.ShowAccelChar;
  Dest.WordWrap := Source.WordWrap;
end;

procedure InitializeWizard();
var
  S: string;
begin
  // ...

  FakeFinishedPage := CreateCustomPage(UserPage1.ID, '', ''); 
  FakeFinishedPage.OnActivate := @FakeFinishedPageActivate;

  FakeFinishedBitmapImage := TBitmapImage.Create(WizardForm);
  FakeFinishedBitmapImage.Parent := FakeFinishedPage.Surface;
  FakeFinishedBitmapImage.BackColor := WizardForm.WizardBitmapImage2.BackColor;
  FakeFinishedBitmapImage.Bitmap := WizardForm.WizardBitmapImage2.Bitmap;
  FakeFinishedBitmapImage.Stretch := WizardForm.WizardBitmapImage2.Stretch;

  FakeFinishedLabel := TNewStaticText.Create(WizardForm);
  FakeFinishedLabel.Parent := FakeFinishedPage.Surface;
  CopyLabel(FakeFinishedLabel, WizardForm.FinishedLabel);
  S :=
    SetupMessage(msgFinishedLabelNoIcons) + #13#13 +
    SetupMessage(msgClickFinish);
  StringChangeEx(S, '[name]', 'My Program', True);
  FakeFinishedLabel.Caption := S;

  FakeFinishedHeadingLabel := TNewStaticText.Create(WizardForm);
  FakeFinishedHeadingLabel.Parent := FakeFinishedPage.Surface;
  CopyLabel(FakeFinishedHeadingLabel, WizardForm.FinishedHeadingLabel);
  S := SetupMessage(msgFinishedHeadingLabel);
  StringChangeEx(S, '[name]', 'My Program', True);
  FakeFinishedHeadingLabel.Caption := S;
end;

enter image description here


There are some limitations:


Though to avoid all these hacks, consider allowing the installation to proceed normally, but without changing anything. It might be easier to implement in the end.


Related questions:

Upvotes: 1

Related Questions