Inno Setup custom wizard pages ("installation checklist") change text at runtime - inno-setup

I made a custom wizard page, and I want it to show a sort of installation checklist at the end of the install, showing what installed successfully or not.
Something like
Crucial Step......................SUCCESS
Optional Step.....................FAILURE
So I have this code in my initializeWizard()
Page := CreateCustomPage(wpInstalling, 'Installation Checklist', 'Status of all installation components');
RichEditViewer := TRichEditViewer.Create(Page);
RichEditViewer.Width := Page.SurfaceWidth;
RichEditViewer.Height := Page.SurfaceHeight;
RichEditViewer.Parent := Page.Surface;
RichEditViewer.ScrollBars := ssVertical;
RichEditViewer.UseRichEdit := True;
RichEditViewer.RTFText := ''// I want this attribute to be set in CurStepChanged()
Is there a way to add or edit RichEditViewer.RTFText at a later point in time? Page is a global variable but trying to access any attributes gives me an error. I'd like to do edit the text after wpInstalling, so I can tell whether or not install steps were successful.

I'm not a huge fan of this method, but you Can set your RichEditViewer as a global, and then editing it at any point, in any function, is trivial.
var
RichEditViewer: TRichEditViewer;
procedure InitializeWizard();
var
Page: TWizardPage;
begin
Page := CreateCustomPage(wpInstalling, 'Installation Checklist', '');
RichEditViewer := TRichEditViewer.Create(Page);
RichEditViewer.Width := Page.SurfaceWidth;
RichEditViewer.Height := Page.SurfaceHeight;
RichEditViewer.Parent := Page.Surface;
RichEditViewer.ScrollBars := ssVertical;
RichEditViewer.UseRichEdit := True;
end;
procedure CurStepChanged(CurStep: TSetupStep);
begin
if CurStep=ssPostInstall then RichEditViewer.RTFText := 'STUFF';
end;
Worthwhile to note, the page itself doesn't even need to be global.

Related

How to show password while typing in Inno Setup?

I have created a setup with Inno Setup via Wizard method and used a password. But when I ran setup and in Password screen, password is hidden while typing (****). I want password to be shown while typing.
Can somebody guide me?
Set TPasswordEdit.Password property of WizardForm.PasswordEdit to False:
<event('InitializeWizard')>
procedure InitializeWizardRevealPassword();
begin
WizardForm.PasswordEdit.Password := False;
end;
If you want to allow the user to toggle the display of the password, you have to add a custom checkbox.
var
ShowPasswordCheck: TNewCheckBox;
procedure ShowPasswordCheckClick(Sender: TObject);
begin
WizardForm.PasswordEdit.Password := not ShowPasswordCheck.Checked;
end;
<event('InitializeWizard')>
procedure InitializeWizardRevealPassword();
begin
ShowPasswordCheck := TNewCheckBox.Create(WizardForm);
ShowPasswordCheck.Parent := WizardForm.PasswordEdit.Parent;
ShowPasswordCheck.Caption := '&Show password';
ShowPasswordCheck.Top :=
WizardForm.PasswordEdit.Top + WizardForm.PasswordEdit.Height + ScaleY(8);
ShowPasswordCheck.Height := ScaleY(ShowPasswordCheck.Height);
ShowPasswordCheck.Checked := not WizardForm.PasswordEdit.Password;
ShowPasswordCheck.OnClick := #ShowPasswordCheckClick;
end;

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,
Needs to look like this,
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.
Recreate the FinishedPage controls on your custom page.
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;
There are some limitations:
The code does not handle correctly image resizes, when the wizard resizes (with WizardResizable=yes) – it's easy to fix though.
The solution does not expect that any page will be shown after this fake finish pages shows. I.e. there's no Back button and it's expected that the Finish button is implement to kill the intallater. After all, this is a follow up question to Conditionally skip to a custom page at the end of the Inno Setup installation wizard without installing?
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:
Image covering whole page in Inno Setup – An alternative implementation that solves the problem by overlaying a control over whole upper part of the wizard window, hiding/showing it as needed.
Custom Welcome and Finished page with stretched image in Inno Setup
How to hide the main panel and show an image over the whole page?

Display a message in separate window visible throughout an installation

I already used InfoBeforeFile directive, with an "Important notice" text file.
But I would prefer the user could continue to read the instructions throughout an installation (e.g. in a separate window).
Any clue?
Added the final result, thanks again to Martin Prikryl
Use CreateCustomForm function to create a separate window for your message.
[Files]
Source: "important.txt"; Flags: dontcopy;
[Code]
procedure InitializeWizard();
var
InfoForm: TSetupForm;
InfoMemo: TRichEditViewer;
begin
InfoForm := CreateCustomForm;
Log(IntToStr(WizardForm.Left));
Log(IntToStr(WizardForm.Width));
InfoForm.Left := WizardForm.Left + WizardForm.Width;
InfoForm.Width := ScaleX(400);
InfoForm.Caption := 'Important message';
InfoForm.Top := WizardForm.Top;
InfoForm.Height := WizardForm.Height;
InfoForm.Position := poDesigned;
InfoForm.Show();
InfoMemo := TRichEditViewer.Create(InfoForm);
InfoMemo.Parent := InfoForm;
InfoMemo.Left := ScaleX(40);
InfoMemo.Top := ScaleX(40);
InfoMemo.Width := InfoForm.ClientWidth - 2 * ScaleX(40);
InfoMemo.Height := InfoForm.ClientHeight - 2 * ScaleX(40);
InfoMemo.ScrollBars := ssVertical;
InfoMemo.ReadOnly := ssVertical;
InfoMemo.WantReturns := ssVertical;
InfoMemo.WantReturns := False;
ExtractTemporaryFile('important.txt');
InfoMemo.Lines.LoadFromFile(ExpandConstant('{tmp}\important.txt'));
end;
Though, wouldn't it be better to display the message on the side of the installer wizard?

Welcome page not showing, SelectDir page is showing first instead

I'm trying to make installer using Inno Setup.
And I want to show Welcome page first, then SelectDir.
This is CurPageChanged example code:
procedure CurPageChanged(CurPageID: integer);
begin
if CurPageID = wpWelcome then
begin
HideComponents;
WLabel.show;
WizardForm.NextButton.Show;
WizardForm.NextButton.Caption := 'Configure';
end;
if CurPageID = wpSelectDir then
begin
HideComponents;
BmpFile.Bitmap.LoadFromFile(ExpandConstant('{tmp}\2.bmp'));
WizardForm.DirEdit.Show;
WizardForm.NextButton.Show;
WizardForm.NextButton.Caption := 'Install';
WizardForm.DirBrowseButton.Show;
TasksSeparateBevel.Show;
TasksSeparateBevel2.Show;
InstallpathLabel.Show;
DiskSpaceLablel.Show;
ShortcutLabel.Show;
ShortcutCB.Show;
CreateDLabel.Show;
end;
if CurPageID = wpInstalling then
begin
HideComponents;
MakeSlideShow;
TimerID := SetTimer(0, 0, 10000, WrapTimerProc(#OnTimer, 4));
WizardForm.CancelButton.show;
WizardForm.ProgressGauge.show;
end;
end;
But the SelectDir shows first then Install. Welcome page does not show!
The Welcome page is by default skipped since Inno Setup 5.5.7:
As recommended by Microsoft's desktop applications guideline, DisableWelcomePage now defaults to yes. ... The defaults in all previous versions were no.
To show it, you have to set:
[Setup]
DisableWelcomePage=no
Thought as mentioned in the quote above, the defaults are recommended, so you should follow them.

Inno Setup disable Installing Wizard Pages

Is it possible to disable the the Preparing To Install wpPreparing and the Installing wpInstalling Wizard Pages (i.e. the ones with the progress bar) so that they do not show during installation? There does not appear to be a built-in directive or method (e.g. for the Ready Wizard Page you can use DisableReadyPage=yes to do so). Am I missing something, or is it, as I suspect, simply not possible?
I have already tried using:
function ShouldSkipPage(CurPageID: Integer): Boolean;
begin
if CurPageID = wpPreparing then
Result := True;
if CurPageID = wpInstalling then
Result := True;
end;
Have you tried this - DisableReadyPage=yes in the [Setup] section.
Seems the only other option is to use the "install silently" command line switch. I'd be careful though this essentially installs a potentially destructive program without the users knowledge.
It is not possible to skip the wpPreparing or wpInstalling Wizard Pages. However, if the installer is not actually installing anything and is being used to return something, say an unlock code, as is the use case here, the following could be done instead:
//Disable the Exit confirmation prompt
procedure CancelButtonClick(CurPageID: Integer; var Cancel, Confirm: Boolean);
begin
Cancel := True;
Confirm := False;
end;
function NextButtonClick(CurPageID: Integer): Boolean;
begin
//Get the unlock code
if CurPageID = UnlockCodePage.ID then
begin
if UnlockCodePage.Values[0] = '' then
begin
MsgBox('You must enter an installation ID to generate an unlock code.',
mbError, MB_OK);
end
else
begin
UnlockCodePage.Values[1] := GetUnlockCode;
end;
Result := False;
end;
end;
procedure CurPageChanged(CurPageID: Integer);
begin
//Define button visibility, whether the Back button is enabled and change the Next and Cancel button labels
WizardForm.CancelButton.Caption := '&Close';
if CurPageID = UnlockCodePage.ID then
begin
WizardForm.BackButton.Enabled := False;
WizardForm.NextButton.Caption := '&Generate';
end;
end;
Hopefully this may help someone looking to do something similar.

Resources