首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >当一个盒子被选中时,我想要另一个被选中。

当一个盒子被选中时,我想要另一个被选中。
EN

Stack Overflow用户
提问于 2015-08-19 09:37:36
回答 1查看 43关注 0票数 0

我有下两节课

代码语言:javascript
复制
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

在安装过程中,当用户选中第二个“控制系统工具箱”,自动选中第一个“通信工具箱”时,我想要被检查,并在此时显示一条消息“安装控制系统工具箱你还需要安装”通信工具箱“。我怎么能做到这一点?

我试图在“控制系统工具箱”中放置一个文本框:

代码语言:javascript
复制
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

我不明白为什么在我按下按钮后,没交上一页?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-08-19 12:00:31

处理此问题的方法有两种:

A)在组件页面上强制执行需求:

代码语言:javascript
复制
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页面上执行部分代码),并在需要时强制安装组件:

代码语言:javascript
复制
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
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32091795

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档