我接下来的两节
Section /o "Communications Toolbox"
;SectionIn RO
FileWrite $9 "product=Communications Toolbox$\r$\n"
AddSize 0
SectionEnd
Section /o "Control System Toolbox"
;SectionIn RO
FileWrite $9 "product=Control System Toolbox$\r$\n"
AddSize 0
SectionEnd
并且在安装过程中,当用户检查第二个"控制系统工具箱"时,自动检查第一个"通信工具箱"我想要检查,并在那一刻显示一条消息"要安装Control System Toolbox,您还需要安装" Communications Toolbox"。 我怎么能做到这一点?
我试图将一个文本框放在"控制系统工具箱" :
Section /o "Control System Toolbox"
MessageBox MB_OK "Do you want to stay in the license page?" IDOK
Abort
FileWrite $9 "product=Control System Toolbox$\r$\n"
AddSize 0
SectionEnd
我不明白为什么按下按钮后确定,上一页没有翻过来?
答案 0 :(得分:1)
有两种方法可以解决这个问题:
A)强制执行组件页面上的要求:
Page Components
Page InstFiles
Section /o "Main Component" SID_MAIN
DetailPrint "Installing Main Component..."
SectionEnd
Section /o "Bonus feature" SID_BONUS
DetailPrint "Installing bonus Component..."
SectionEnd
!include Sections.nsh
!include LogicLib.nsh
Function .OnSelChange
${If} ${SectionIsSelected} ${SID_BONUS}
!insertmacro SelectSection ${SID_MAIN} ; The main component is required when installing the bonus component
!insertmacro SetSectionFlag ${SID_MAIN} ${SF_RO}
${Else}
!insertmacro ClearSectionFlag ${SID_MAIN} ${SF_RO}
${EndIf}
FunctionEnd
您还可以在其他问题中使用I suggested等栏目组。
B)在安装阶段使用MessageBox(部分代码在InstFiles页面上执行)并强制安装组件(如果需要):
Page Components
Page InstFiles
Section "" ; Hidden section
Call EnsureRequiredSections ; We have to call a function because SID_MAIN has not been defined yet
SectionEnd
Section "Main Component" SID_MAIN
DetailPrint "Installing Main Component..."
SectionEnd
Section /o "Bonus feature" SID_BONUS
DetailPrint "Installing bonus Component..."
SectionEnd
!include Sections.nsh
!include LogicLib.nsh
Function EnsureRequiredSections
${If} ${SectionIsSelected} ${SID_BONUS}
${AndIfNot} ${SectionIsSelected} ${SID_MAIN}
MessageBox MB_YESNO|MB_ICONQUESTION "Main Component is required when installing the Bonus feature, do you want to install both?" IDNO no
!insertmacro SelectSection ${SID_MAIN}
Goto done
no:
!insertmacro UnSelectSection ${SID_BONUS}
done:
${EndIf}
FunctionEnd