views:

565

answers:

2

I added a few custom pages to my setup. In one of this custom pages I do some checks. If this checks failed, I want switch to finish page. How can I do this?

I can not do this with ShouldSkipPage event function because:

function ShouldSkipPage(PageID: Integer): Boolean;
begin
  // this will NEVER happened - see documentation below
  if (PageID = wpInstalling) or (PageID = wpPreparing) or (PageID = wpWelcome) then
  begin
    // skip install - simply for example
    result := True;
    exit;
  end;

  resutl := false;
end;

From Inno Setup documentation:

The wizard calls this event function to determine whether or not a particular page (specified by PageID) should be shown at all. If you return True, the page will be skipped; if you return False, the page may be shown.

Note: This event function isn't called for the wpWelcome, wpPreparing, and wpInstalling pages, nor for pages that Setup has already determined should be skipped (for example, wpSelectComponents in an install containing no components).

+1  A: 

I'm sorry, i did not understand why you cannot use ShouldSkipPage. The usual way of doing it is in ShouldSkipPage:

function ShouldSkipPage(curPageId : Integer) : Boolean;
begin
  {For a certain condition, skip to wpFinished}
  if (SomeCondition and (curPageId <> wpFinished)) then
    Result := True
  {Probably more checks}
  else
    Result := False
end;
Please, see my comment in question. This can not be done.
Sasha
+1, good answer. @Sasha - try it, it does work. But you may need to add checks to skip your normal installation steps too if you need to bail out.
mghie
DO NOT WORK. See my question!
Sasha
@Sasha: That's not encouraging people to help you.
mghie
@mghie I add some code to my question.
Sasha
A: 

If I understand you correctly, you are performing a check, and if it fails, you want to skip wpWelcome, wpPreparing, and wpInstalling (and perhaps more custom pages).

I assume that you also want to skip the actions performed when these pages are shown, specifically, you don't want to perform the installation step.

If that is the case, you should cancel the installation, not continue it without performing the actual installation steps. You can do it in InitializeSetup, for example:

Procedure InitializeSetup();
VAR
  Check: Integer;
BEGIN
  // perform you check here, set the variable according to it's result

  IF (Check <> 0) THEN
    // abort installation
    Return False;
  ELSE
    Return True;
END;

Edit
In response to your comment: The easiest solution would be to show a message box with the result of your check, instead of a complete wizard page. If that is not enough for your purposes I would suggest the following approach:

  1. Perform your check in InitializeSetup and store the result in a global variable.

  2. Create a new wizard page (lets call it CheckResult) to display the results of your check, it should be displayed directly after wpWelcome.

  3. In that page's OnNextButtonClick just call CancelButtonClick, that way the installation is always aborted when this page is displayed

  4. Now is the time to modify ShouldSkipPage ;-) If the global check variable indicates that everything is ok, skip your CheckResult page, so that the installation is not aborted automatically

This should work, but if you somehow can, follow the KISS principle and go with the message box approach.

Treb
Before exit from installation I want to show a user the page with result of my check.
Sasha

related questions