代码之家  ›  专栏  ›  技术社区  ›  user2455111

NSIS:组件检查事件的组件页面

  •  1
  • user2455111  · 技术社区  · 7 年前

    我使用NSIS安装我的项目。当我在组件页面上选择要安装的部分时,我需要显示带有警告文本的MessageBox。是否有某种方法可以跟踪对复选框的点击,可能是事件或其他?

    1 回复  |  直到 7 年前
        1
  •  1
  •   Anders    7 年前

    使用 .onSelChange callback

    在NSIS 3中,更改的节id存储在$0中:

    Page Components
    Page InstFiles
    
    Section /o "Foo" SID_FOO
    SectionEnd
    
    Section "Bar"
    SectionEnd
    
    !include LogicLib.nsh
    
    Function .onSelChange
    ${If} ${SectionIsSelected} ${SID_FOO}
    ${AndIf} $0 = ${SID_FOO}
        MessageBox MB_ICONEXCLAMATION "Warning, section Foo selected!"
    ${EndIf}
    FunctionEnd
    

    Page Components
    Page InstFiles
    
    Section /o "Foo" SID_FOO
    SectionEnd
    
    Section "Bar"
    SectionEnd
    
    !include LogicLib.nsh
    
    Var hasWarned
    
    Function .onSelChange
    ${If} ${SectionIsSelected} ${SID_FOO}
    ${AndIf} $hasWarned = 0
        StrCpy $hasWarned 1
        MessageBox MB_ICONEXCLAMATION "Warning, section Foo selected!"
    ${EndIf}
    /* Uncomment this to display the warning every time it is selected
    ${IfNot} ${SectionIsSelected} ${SID_FOO}
        StrCpy $hasWarned 0
    ${EndIf}
    */
    FunctionEnd