Reputation: 1790
I'm trying to make my setup stop when all components are already install.
Installation Example :
wpFinished
page or stop and put a message saying "all component are already install".I've make some research here and on other website and I have do the following :
procedure CancelButtonClick(CurPageID: Integer; var Cancel, Confirm: Boolean);
begin
Confirm := False;
end;
procedure InitializeWizard;
var
ItemIndex: Integer;
InstallEn: String;
InstallFr: String;
InstallDe: String;
CompDescEnIndex: Integer;
CompDescFrIndex: Integer;
CompDescDeIndex: Integer;
Check: Integer;
begin
# This part is to make not selectable component already install
if RegQueryStringValue(HKLM, 'Software\COMPANY\{#RegProduct}\{#RegCurVer}', 'Install-ENG', InstallEn) then
if ((InstallEn = 'International Pack' )
or (InstallEn = 'Pack International')
or (InstallEn = 'International Paket'))
then
ItemIndex := WizardForm.ComponentsList.Items.IndexOf(CustomMessage('CompDescEn'));
WizardForm.ComponentsList.ItemEnabled[ItemIndex] := False;
if RegQueryStringValue(HKLM, 'Software\COMPANY\{#RegProduct}\{#RegCurVer}', 'Install-FRA', InstallFr) then
if ((InstallFr = 'French Pack')
or (InstallFr = 'Pack France')
or (InstallFr = 'Franzosisch Paket'))
then
ItemIndex := WizardForm.ComponentsList.Items.IndexOf(CustomMessage('CompDescFr'));
WizardForm.ComponentsList.ItemEnabled[ItemIndex] := False;
if RegQueryStringValue(HKLM, 'Software\COMPANY\{#RegProduct}\{#RegCurVer}', 'Install-DEU', InstallDe) then
if ((InstallDe = 'German Pack')
or (InstallDe = 'Pack Allemand')
or (InstallDe = 'Deutsches Paket'))
then
ItemIndex := WizardForm.ComponentsList.Items.IndexOf(CustomMessage('CompDescDe'));
WizardForm.ComponentsList.ItemEnabled[ItemIndex] := False;
# After I try to say if all component are install, close the wizard.
CompDescEnIndex := WizardForm.ComponentsList.Items.IndexOf(CustomMessage('CompDescEn'));
CompDescFrIndex := WizardForm.ComponentsList.Items.IndexOf(CustomMessage('CompDescFr'));
CompDescDeIndex := WizardForm.ComponentsList.Items.IndexOf(CustomMessage('CompDescDe'));
if not WizardForm.ComponentsList.ItemEnabled[CompDescEnIndex]
and not WizardForm.ComponentsList.ItemEnabled[CompDescFrIndex]
and not WizardForm.ComponentsList.ItemEnabled[CompDescDeIndex]
then
Check := 1;
if (Check <> 0) then
WizardForm.Close;
end;
Note: Code may not be very clean, I started in Pascal + Inno Setup in the Code
section.
If all my component are installed (and not selectable), I want the wizard to stop and not continue...
I can't find a solution to go directly at wpFinished
page... Is there a way to do that?
How can I stop the wizard if all component are installed because WizardForm.Close;
seems not work in my case?
Thanks for help.
Upvotes: 0
Views: 644
Reputation: 202272
You cannot skip to the wpFinished
page as Inno Setup does not allow you to skip the wpReady
page to avoid creating a fully-automated installers (which might be abused).
You can create a custom "finished" page though:
procedure AllInstalledPageActivate(Sender: TWizardPage);
begin
{ Change the "Next" button to "Finish" on our custom page }
WizardForm.NextButton.Caption := SetupMessage(msgButtonFinish);
{ Hide the "Cancel" button }
WizardForm.CancelButton.Visible := False;
end;
procedure ExitProcess(uExitCode: UINT);
external '[email protected] stdcall';
function AllInstalledPageNextButtonClick(Sender: TWizardPage): Boolean;
begin
{ Abort the installer when the "Finish" button is clicked on our custom page }
ExitProcess(0);
Result := True; { shut up the compiler warning }
end;
procedure InitializeWizard();
var
Caption: TLabel;
AllInstalledPage: TWizardPage;
begin
...
{ If everything is installed already ... }
if IsEverythingInstalled then
begin
{ ... create a custom "everything is installed" page }
AllInstalledPage :=
CreateCustomPage(
wpWelcome, 'All components are installed already',
'There''s nothing to install.');
AllInstalledPage.OnActivate := @AllInstalledPageActivate;
AllInstalledPage.OnNextButtonClick := @AllInstalledPageNextButtonClick;
Caption := TLabel.Create(AllInstalledPage);
Caption.Caption :=
'Everything is installed already. Click Finish to close the installer.';
Caption.Width := AllInstalledPage.SurfaceWidth;
Caption.Parent := AllInstalledPage.Surface;
end;
end;
Even simpler solution is to use a plain message box.
The Wizard.Close
would close the installer, it would not go to the "Finished" page anyway. If you really want to abort the installer, return False
from InitializeSetup
(you would need to move some of your code to the InitializeSetup
).
Or use the ExitProcess
function, as in my example.
Upvotes: 2