Inno设置查询跳过页面功能

时间:2015-03-25 09:01:32

标签: inno-setup pascal

我正在创建一个设置,它涉及根据我在第3页中获得的值有条件地跳过页面。我在InitializeWizard()中创建了所有可能的页面,在调试时我可以看到创建的所有页面。当我尝试跳过ShouldSkipPage中的页面时,我无法按预期跳过。

在哪种情况下,页面无效或有任何方法可以检查日志或有关页面状态的信息。

P.S - 页面非常有效且可用,我只能跳过它。

下面给出了代码段......

[Code]

var
PageSQL2008SetupFile2: Integer;
PageSQL2008R2SetupFile2: Integer;
PageSQL2012SetupFile2: Integer;
PageSQL2014SetupFile2: Integer;

procedure InitializeWizard();
begin
        MyModeTypical := false;

                PageProductName := CreateInputQueryPage(wpSelectComponents,
                'Settings',
                'Product Name',
                'Please specify the product name, then click Next.');

                PageProductName.Add('Product Name:', False);
                PageProductName.Values[0] := ProductName;
//SQL Server selection page
                PageSQLServerSelection := CreateInputOptionPage(PageProductName.ID,
                'SQL Server Selection', 'Please select the version of SQL Server you want to install.',
                '',
                True, False);

                PageSQLServerSelection.Add('SQL 2008');
                PageSQLServerSelection.Add('SQL 2008R2');
                PageSQLServerSelection.Add('SQL 2012');
                PageSQLServerSelection.Add('SQL 2014');

                PageSQLServerSelection.Values[0] := False;
                PageSQLServerSelection.Values[1] := False;
                PageSQLServerSelection.Values[2] := False;
                PageSQLServerSelection.Values[3] := False;

// Creating Setup pages for the 4 servers
                PageSQL2008SetupFile2 := MSSQL2008SETUPDIR_CreatePage(PageSQLServerSelection.ID);

                PageSQL2008R2SetupFile2 := MSSQL2008R2SETUPDIR_CreatePage(PageSQL2008SetupFile2);

                PageSQL2012SetupFile2 := MSSQL2012SETUPDIR_CreatePage(PageSQL2008R2SetupFile2);

                PageSQL2014SetupFile2 := MSSQL2014SETUPDIR_CreatePage(PageSQL2012SetupFile2);

// some more logic...

end;

// Function for creating the Setup pages for 4 SQL Servers (Same logic for all 4 servers)

function MSSQL2008SETUPDIR_CreatePage(PreviousPageId: Integer): Integer;
var
  Page: TWizardPage;
  BMPFile: String;
begin
  SelectedSQLServerVersion := GetSQLServerVersion('');
  Page := CreateCustomPage(
    PreviousPageId,
    ExpandConstant('Database Settings'),
    ExpandConstant('Special note for the Microsoft SQL Server 2008 Setup')
  );

        BMPFile:= ExpandConstant('{tmp}\caution.bmp');
        if not FileExists(BMPFile) then ExtractTemporaryFile(ExtractFileName(BMPFile));
{ BitmapImage1 }
  BitmapImage1 := TBitmapImage.Create(Page);
  with BitmapImage1 do
  begin
        Bitmap.LoadFromFile(BMPFile);
    Parent := Page.Surface;
    Left := ScaleX(8);
    Top := ScaleY(8);
    Width := ScaleX(97);
    Height := ScaleY(209);
  end;
  { NewStaticText1 }
  NewStaticText1 := TNewStaticText.Create(Page);
  with NewStaticText1 do
  begin
    Parent := Page.Surface;
        Caption := 'To install Microsoft SQL Server 2008 you have to insert the Microsoft SQL Server 2008 Setup CD, when XXX setup requests it. The installation path of your Microsoft SQL Server 2008 setup and the additional Service Packs can be defined on the next pages.';
        Left := ScaleX(112);
    Top := ScaleY(8);
    Width := ScaleX(292);
    Height := ScaleY(77);
    AutoSize := False;
    TabOrder := 0;
    WordWrap := True;
  end;

  { NewStaticText2 }
  NewStaticText2 := TNewStaticText.Create(Page);
  with NewStaticText2 do
  begin
    Parent := Page.Surface;
    Caption :=
      'CAUTION: When autorun is activated, dont click in the autorun menu of Microsoft SQL Server 2008.' + #13 +
      'Otherwise you must reboot your machine and restart the setup !';
    Left := ScaleX(112);
    Top := ScaleY(88);
    Width := ScaleX(293);
    Height := ScaleY(62);
    AutoSize := False;
    Font.Color := -16777208;
    Font.Height := ScaleY(-11);
    Font.Name := 'Tahoma';
    Font.Style := [fsBold];
    ParentFont := False;
    TabOrder := 1;
    WordWrap := True;
  end;

  with Page do
  begin
    //OnActivate := @MSSQLSETUPDIR_Activate;
    //OnShouldSkipPage := @MSSQLSETUPDIR_ShouldSkipPage;
        //OnBackButtonClick := @MSSQLSETUPDIR_BackButtonClick;
    //OnNextButtonClick := @MSSQLSETUPDIR_NextButtonClick;
    //OnCancelButtonClick := @MSSQLSETUPDIR_CancelButtonClick;
  end;

  Result := Page.ID;
end;

function ShouldSkipPage(PageID: Integer): Boolean;

var

begin
        if PageID = wpSelectComponents then begin
                Result := MyModeTypical;
        end else if PageID = PageProductName.ID then begin
                Result := MyModeTypical;
        end;
        Log('Server is...' + SelectedSQLServerVersion);
        if SelectedSQLServerVersion <> '' then begin
        // Database Settings Warning
                if (SQLServer2008Flag = True) and (IsComponentSelected('DBS\SERVER')) then begin
                        if PageID = PageSQL2008SetupFile2 then begin
                                Result := false;
                        end else if PageID = PageSQL2008R2SetupFile2 then begin
                                Result := true;
                        end else if PageID = PageSQL2012SetupFile2 then begin
                                Result := true;
                        end else if PageID = PageSQL2014SetupFile2 then begin
                                Result := true;
                        end;

                end else if (SQLServer2008R2Flag = True) and (IsComponentSelected('DBS\SERVER')) then begin
                        if PageID = PageSQL2008R2SetupFile2 then begin
                                Result := false;
                        end else if PageID = PageSQL2012SetupFile2 then begin
                                Result := true;
                        end else if PageID = PageSQL2014SetupFile2 then begin
                                Result := true;
                        end else if PageID = PageSQL2008SetupFile2 then begin
                                Result := true;
                        end;

                end else if (SQLServer2012Flag = True) and (IsComponentSelected('DBS\SERVER')) then begin
                        if PageID = PageSQL2012SetupFile2 then begin
                                Result := false;
                // This PageSQL2014SetupFile2 is not skipped.....
                        end else if PageID = PageSQL2014SetupFile2 then begin
                                Result := true;
                // This PageSQL2008SetupFile2 and PageSQL2008R2SetupFile2 are skipped properly.....
                        end else if PageID = PageSQL2008SetupFile2 then begin
                                Result := true;
                        end else if PageID = PageSQL2008R2SetupFile2 then begin
                                Result := true;
                        end;

                end else if (SQLServer2014Flag = True) and (IsComponentSelected('DBS\SERVER')) then begin
                        if PageID = PageSQL2014SetupFile2 then begin
                                Result := false;
                        end else if PageID = PageSQL2008SetupFile2 then begin
                                Result := true;
                        end else if PageID = PageSQL2008R2SetupFile2 then begin
                                Result := true;
                        end else if PageID = PageSQL2012SetupFile2 then begin
                                Result := true;
                        end;
                end;
// some more logic

end;

节目播音员

0 个答案:

没有答案
相关问题