Inno setup 如果你回去,如何避免提出一个页面

Inno setup 如果你回去,如何避免提出一个页面,inno-setup,Inno Setup,我在InnoSetup中制作了一个脚本(我的第一个脚本),除了在特定条件下,它工作得非常好。让我解释一下: 这是我的新脚本: [Types] Name: "Base"; Description: "Local Database"; Flags: iscustom [Components] Name: "baselocal"; Description: "Standard Installation : install program and local database"; Types: Bas

我在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正在工作,但如果我选择“baseserver”两次(一次,返回并重新选择一次…我知道这是扭曲的,但我测试了所有可能性),它会连续两次提出“baseserver”

有没有办法避免这种情况


提前谢谢

您是否尝试添加
布尔值
作为附加条件

[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;

我很快就会忘记
baseserverbool
变量所做的事情。变量,例如
BasePageCreated
更能描述其用途。在这种情况下,它实际上是
DirPageCreated
。但是无论如何,你不需要使用一个变量。如果没有分配(DirPage),只需询问
,然后…
。当您创建该页面时,您正在将其分配给该变量,因此下次
DirPage
变量将有
分配的对象实例。嗯,我尝试了您的解决方案(@Roben和@TLama中的“if not Assigned”),但问题仍然存在。如果我更改通知,首先选择“baseserver”,返回组件页面并选择“baselocal”,它仍然会提出“dirpage”。。。(或者可能我写错了代码)也许你应该在返回时销毁
页面,或者在这种情况下添加
ShouldSkipPage
?是的,我就是这么做的,我编辑了我的脚本,现在我遇到了另一个问题。看上面:)