如果您返回,如何避免提议页面

How to avoid proposing a page if you go back

我在 InnoSetup 中制作了一个脚本(我的第一个脚本),除了在特定条件下,它工作得很好。让我解释一下:

这是我的脚本:

[Types]
Name: "Base"; Description: "Local Database"; Flags: iscustom

[Components]
Name: "baselocal"; Description: "Standard Installation : install program and local database"; Types: Base; Flags: exclusive
Name: "baseserver"; Description: "Installation with server database : install program and choose directory for database"; Types: Base; Flags: exclusive

...

[code]
var
  BasePage: TInputDirWizardPage;
  BasePageID: Integer;

function NextButtonClick(CurPageID: Integer): Boolean;
begin
  Result := True;
  if CurPageID = wpSelectComponents then begin
    if (IsComponentSelected('baseserver')) then
                begin

                  Result := (MsgBox('La base ne sera pas installée localement. Vous devrez spécifiez un chemin. ' +
                  'Voulez-vous continuer ?', mbConfirmation, MB_YESNO) = IDYES);
                  // create a directory input page
                  BasePage := CreateInputDirPage(wpSelectComponents, 'Choix de la base', 'Caneco BT peut gérer une base sur un serveur ou en local. Veuillez indiquez le chemin de la base qui vous intéresse.', 'Dossier Base de Données', False, '');
                  // add directory input page items
                  BasePage.Add('Sélectionnez un chemin :');
                  // assign default directories for the items from the previously stored data; if
                  // there are no data stored from the previous installation, use default folders
                  // of your choice
                  BasePage.Values[0] := GetPreviousData('Directory1', ExpandConstant('{pf}\program\'));
                  BasePageID := BasePage.ID;
                  exit;
                end;     
  end;
end;

function ShouldSkipPage(PageID: Integer): Boolean;
begin
  // initialize result to not skip any page (not necessary, but safer)
  Result := False;
  // if the page that is asked to be skipped is your custom page, then...
  if PageID = BasePageID then
    // if the component is not selected, skip the page
    Result := not IsComponentSelected('baseserver');
end;

(如有错误,请告诉我,谢谢)

现在使用 "ShouldSkipPage" 函数,ti 可以工作,但是如果我 select "baseserver" 两次(一次,回来重新 select 一次...我知道这是扭曲的,但我测试了所有可能性),它连续两次提出 "BasePage"...

有没有办法避免这种情况?

提前致谢

您是否尝试添加 Boolean 作为附加条件?

[Code]
var
  DirPage: TInputDirWizardPage;
  DirPageID: Integer;
  BasePageCreated: Boolean;

function NextButtonClick(CurPageID: Integer): Boolean;
begin
  Result := True;
  if CurPageID = wpSelectComponents then begin
    if (IsComponentSelected('baseserver')) and (not BasePageCreated) then
                begin
                  BasePageCreated := True;
                  // create a directory input page
                  DirPage := CreateInputDirPage(wpSelectComponents, 'Choix de la base', 'Caneco BT peut gérer une base sur un serveur ou en local. Veuillez indiquez le chemin de la base qui vous intéresse.', 'Dossier Base de Données', False, '');
                  // add directory input page items
                  DirPage.Add('Sélectionnez un chemin :');
                  // assign default directories for the items from the previously stored data; if
                  // there are no data stored from the previous installation, use default folders
                  // of your choice
                  DirPage.Values[0] := GetPreviousData('Directory1', ExpandConstant('{pf}\program\'));
                  DirPageID := DirPage.ID;
                  exit;
                end;

    if (IsComponentSelected('baselocal')) or (BasePageCreated) then
       exit;
  end;
end;

初始问题的这个答案

[Types]
Name: "Base"; Description: "Local Database"; Flags: iscustom

[Components]
Name: "baselocal"; Description: "Standard Installation : install program and local database"; Types: Base; Flags: exclusive
Name: "baseserver"; Description: "Installation with server database : install program and choose directory for database"; Types: Base; Flags: exclusive

...

[code]
var
  BasePage: TInputDirWizardPage;
  BasePageID: Integer;

function NextButtonClick(CurPageID: Integer): Boolean;
begin
  Result := True;
  if CurPageID = wpSelectComponents then begin
    if (IsComponentSelected('baseserver')) then
                begin

                  Result := (MsgBox('La base ne sera pas installée localement. Vous devrez spécifiez un chemin. ' +
                  'Voulez-vous continuer ?', mbConfirmation, MB_YESNO) = IDYES);
                  // create a directory input page
                  BasePage := CreateInputDirPage(wpSelectComponents, 'Choix de la base', 'Caneco BT peut gérer une base sur un serveur ou en local. Veuillez indiquez le chemin de la base qui vous intéresse.', 'Dossier Base de Données', False, '');
                  // add directory input page items
                  BasePage.Add('Sélectionnez un chemin :');
                  // assign default directories for the items from the previously stored data; if
                  // there are no data stored from the previous installation, use default folders
                  // of your choice
                  BasePage.Values[0] := GetPreviousData('Directory1', ExpandConstant('{pf}\program\'));
                  BasePageID := BasePage.ID;
                  exit;
                end;     
  end;
end;

function ShouldSkipPage(PageID: Integer): Boolean;
begin
  // initialize result to not skip any page (not necessary, but safer)
  Result := False;
  // if the page that is asked to be skipped is your custom page, then...
  if PageID = BasePageID then
    // if the component is not selected, skip the page
    Result := not IsComponentSelected('baseserver');
end;