Inno Setup Skip custom page after execution of some scripts - inno-setup

so i am currently trying to modify the setup script,
What i was trying to do was after installing i enter in a custom page, this custom page executes 2 scritps(one for creating the database and the other for creating the tables).
while this is executing i want to display a custom label,and a continuous progress bar.
When the execution finish, i want to go directly to the finish page.
I wanto to also remove the next button.
Is this possible?
For the moment i have the custom page with a constinuous progress bar, this page appears after install.i will then add the label after finishing the progress bar part.
here is my code:
[CODE]
var
Page: TWizardPage;
ProgressBar3: TNewProgressBar;
procedure CreateTheWizardPages;
begin
Page := CreateCustomPage(wpInstalling, 'Base de dados', 'A verificar a base de dados');
ProgressBar3 := TNewProgressBar.Create(Page);
ProgressBar3.Left := 5;
ProgressBar3.Width := Page.SurfaceWidth - 5;
ProgressBar3.Parent := Page.Surface;
ProgressBar3.Style := npbstMarquee;
end;
procedure InitializeWizard();
begin
CreateTheWizardPages;
end;
//check the current page,if page equals to wpSelectCompnets, then we add the method on choose to the combobox fo types of installation
procedure CurPageChanged(CurPageID: Integer);
begin
//msgbox(IntToStr( CurPageID),mbInformation, MB_OK);
if CurPageID = wpSelectComponents then
begin
comboboxTypesInstalacao:=WizardForm.TypesCombo;
WizardForm.TypesCombo.OnChange:=#ComboBoxChange;
end
else if CurPageID = Page.ID then
begin
try
CreateDBAndTables('idontimedb.des');
finally
//close this custom wizard page and go to finish page
end;
end;
end;
Thanks in advance.

Related

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?

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.

The official Inno Setup code to change Next button to Install with DisableReadyPage directive does not work

I'm using the code from:
http://www.jrsoftware.org/ishelp/index.php?topic=setup_disablereadypage
It should change the Next button caption to Install when the "Ready" page is disabled using DisableReadyPage directive.
[Setup]
DisableReadyPage=yes
[Code]
procedure CurPageChanged(CurPageID: Integer);
begin
if CurPageID = wpSelectProgramGroup then
WizardForm.NextButton.Caption := SetupMessage(msgButtonInstall)
else
WizardForm.NextButton.Caption := SetupMessage(msgButtonNext);
end;
But it does not change Next button caption.
As the description of the code says:
For example, if the new last pre-installation wizard page is the Select Program Group page: ...
In your case the last pre-installation page is not Select Program Group page. It's the Select Destination Location page. Probably because you have DisableProgramGroupPage set to no, or you have set it to auto and you are upgrading (the application is installed already).
If you have the DisableProgramGroupPage set to no, the solution is simple, as the Select Destination Location page is always the last. Just replace the wpSelectProgramGroup with wpSelectDir.
[Code]
procedure CurPageChanged(CurPageID: Integer);
begin
if CurPageID = wpSelectDir then
WizardForm.NextButton.Caption := SetupMessage(msgButtonInstall)
else
WizardForm.NextButton.Caption := SetupMessage(msgButtonNext);
end;
With auto (the default), you do not get any of Select Program Group and Select Destination Location on upgrade, but you get the Ready to Install even with DisableProgramGroupPage (as there would not be any other page before installation). You can use that fact to use Install both for Select Program Group page (for fresh installs) and Ready to Install (for upgrades).
Another issue with their code is that you should get a Finish button on the "Finished" page (wpFinished). What their code does not care for.
The complete solution is:
procedure CurPageChanged(CurPageID: Integer);
begin
// On fresh install the last pre-install page is "Select Program Group".
// On upgrade the last pre-install page is "Read to Install"
// (forced even with DisableReadyPage)
if (CurPageID = wpSelectProgramGroup) or (CurPageID = wpReady) then
WizardForm.NextButton.Caption := SetupMessage(msgButtonInstall)
// On the Finished page, use "Finish" caption.
else if (CurPageID = wpFinished) then
WizardForm.NextButton.Caption := SetupMessage(msgButtonFinish)
// On all other pages, use "Next" caption.
else
WizardForm.NextButton.Caption := SetupMessage(msgButtonNext);
end;
Had you have other pages, like Tasks page, you would have to alter the code accordingly.
Your screenshot shows the wpSelectDir page while in your code you change the button of the wpSelectProgramGroup page.

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.

Inno Setup remove/hide (not just disable) the Back button on a Wizard Page

I am aware that it is possible to disable (so it appears dimmed) the Back button on a Wizard Page using the following code:
procedure CurPageChanged(CurPageID: Integer);
begin
//Define whether the Back button is enabled
if CurPageID = UnlockCodePage.ID then
begin
WizardForm.BackButton.Enabled := False;
end;
end;
However, is there a way to actually completely remove/hide the Back button so that it can't be seen at all?
You should be able to use the Button.Visible property:
if CurPageID = UnlockCodePage.ID then
WizardForm.BackButton.Visible := False;

Resources