2013-06-03 50 views
0

(我很抱歉,我不能拿出一个更好的标题)插入自定义页面2之间

我有以下的部分代码:

!insertmacro MUI_PAGE_COMPONENTS 
!insertmacro MUI_PAGE_INSTFILES 
Page Custom nsDialogsPage nsDialogsPageLeave 

section Section1 
#do something 
sectionEnd 

section Section2 
#do something else 
sectionEnd 

Function nsDialogsPage 
#do something 
FunctionEnd 

Function nsDialogsPageLeave 
#do something else 
FunctionEnd 

但是,现在我想自定义页面显示在Section1之后和Section2之前(我在第二部分中使用的自定义页面中输入一些信息)。我应该怎么做呢? (我总是可以在MUI_PAGE_INSTFILES之前放置自定义页面,但对于用户来说这看起来很奇怪。)

+0

安装程序在开始对系统进行更改的实际安装步骤之前收集尽可能多的信息很常见,为什么您认为将安装进度分解为这样是一个好主意? – Anders

回答

2

所有部分都在instfiles页面上执行,但可能有多个instfiles页面。为了防止所有部分执行两次,您需要使用sections.nsh中的帮助宏打开/关闭正确的部分,或将某些状态存储在全局变量中,并将所有部分代码放入if块中,例如:${If} $installstep = 0。您可能还需要使用SetAutoClose ...

+0

谢谢,我试过全局变量的想法,它的工作!但是代码看起来非常混乱:) –

0

我用PRE功能选择/取消选择部分:

!insertmacro MUI_PAGE_COMPONENTS 

    !define MUI_PAGE_CUSTOMFUNCTION_PRE checkSkipSection 
    !insertmacro MUI_PAGE_INSTFILES 
    Page Custom nsDialogsPage nsDialogsPageLeave 
    !define MUI_PAGE_CUSTOMFUNCTION_PRE checkSkipSection 
    !insertmacro MUI_PAGE_INSTFILES 

    Var SkipSection 

    section Section1 
    #do something 
    StrCpy $SkipSection 1 
    sectionEnd 

    section Section2 
    #do something else 
    sectionEnd 

    Function nsDialogsPage 
    #do something 
    FunctionEnd 

    Function nsDialogsPageLeave 
    #do something else 
    FunctionEnd 

Function checkSkipSection 

    ${If} $SkipSection = "" 
     SectionSetFlags ${Section1} ${SF_SELECTED} 
     SectionSetFlags ${Section2} 0 

    ${ElseIf} $SkipSection = 1 
     SectionSetFlags ${Section2} ${SF_SELECTED} 
     SectionSetFlags ${Section1} 0 

    ${EndIf} 

FunctionEnd 

所以在第一MUI_PAGE_INSTFILES,只有SECTION1运行,而第2节在第2轮MUI_PAGE_INSTFILES页面。

+0

或者如果您不想使用SkipSection变量,请为自定义页面使用两个单独的函数checkSkipSection1和2,并在每个函数中相应地设置标志。 –