跳过页面:按钮应该说"安装"而不是"下一步"

时间:2015-02-16 23:57:58

标签: nsis

我有一个使用Modern UI 2(MUI 2)的安装程序,它最多可以将三个组件安装到不同的位置

我使用MUI_PAGE_COMPONENTS页面和多个MUI_PAGE_DIRECTORY页面,如果未选择相应的部分,则会自动跳过这些页面(如here所述)。

到目前为止一切顺利。

但是,如果未选择安装三个组件中的最后一个,则上一个(未跳过的)目录页面上的按钮应该说 Install 而不是 Next ,因为接下来将跳过最后一个目录页面并执行安装。

由于我们已经知道在离开组件页面后会跳过哪个页面,我想知道是否有办法让它工作?

最小例子:

!include MUI2.nsh

InstallDir $EXEDIR
OutFile "skip.exe"
RequestExecutionLevel user
ShowInstDetails show

!insertmacro MUI_PAGE_COMPONENTS

!define MUI_PAGE_CUSTOMFUNCTION_PRE directoryPreA
!insertmacro MUI_PAGE_DIRECTORY 

!define MUI_PAGE_CUSTOMFUNCTION_PRE directoryPreB
!insertmacro MUI_PAGE_DIRECTORY 

!insertmacro MUI_PAGE_INSTFILES

!insertmacro MUI_LANGUAGE "English"

Section "A" SEC_A
  DetailPrint "Installing A..."
SectionEnd

Section /o "B" SEC_B
  DetailPrint "Installing B..."
SectionEnd

Function directoryPreA
  # Skips the directory page for A if not chosen for installation.
  ${Unless} ${SectionIsSelected} ${SEC_A}
    Abort
  ${EndUnless}
FunctionEnd

Function directoryPreB
  # Skips the directory page for B if not chosen for installation.
  ${Unless} ${SectionIsSelected} ${SEC_B}
    Abort
  ${EndUnless}
FunctionEnd

1 个答案:

答案 0 :(得分:1)

!include MUI2.nsh
!insertmacro MUI_PAGE_COMPONENTS

!define MUI_DIRECTORYPAGE_TEXT_TOP "Dir:A"
!define MUI_PAGE_CUSTOMFUNCTION_PRE directoryPreA
!insertmacro MUI_PAGE_DIRECTORY 

!define MUI_DIRECTORYPAGE_TEXT_TOP "Dir:B"
!define MUI_PAGE_CUSTOMFUNCTION_PRE directoryPreB
!insertmacro MUI_PAGE_DIRECTORY 

!insertmacro MUI_PAGE_INSTFILES

!insertmacro MUI_LANGUAGE "English"

Section "A" SEC_A
  DetailPrint "Installing A..."
SectionEnd

Section /o "B" SEC_B
  DetailPrint "Installing B..."
SectionEnd

Function .onSelChange
  GetDlgItem $0 $HWNDPARENT 1
  ${If} ${SectionIsSelected} ${SEC_A}
  ${OrIf} ${SectionIsSelected} ${SEC_B}
    SendMessage $0 ${WM_SETTEXT} 0 "STR:$(^NextBtn)"
  ${Else}
    SendMessage $0 ${WM_SETTEXT} 0 "STR:$(^InstallBtn)"
  ${EndIf}
FunctionEnd

Function directoryPreA
  # Skips the directory page for A if not chosen for installation.
  ${IfNot} ${SectionIsSelected} ${SEC_A}
    Abort
  ${ElseIfNot} ${SectionIsSelected} ${SEC_B}
    GetDlgItem $0 $HWNDPARENT 1
    SendMessage $0 ${WM_SETTEXT} 0 "STR:$(^InstallBtn)"
  ${EndIf}
FunctionEnd

Function directoryPreB
  # Skips the directory page for B if not chosen for installation.
  ${Unless} ${SectionIsSelected} ${SEC_B}
    Abort
  ${EndUnless}
FunctionEnd