NSIS:组件检查事件

时间:2017-08-16 04:00:52

标签: installer nsis

我使用NSIS安装我的项目。当我选择一些部分安装在组件页面上时,我需要向MessageBox显示警告文本。有没有办法跟踪复选框上的点击,可能是事件还是什么?

1 个答案:

答案 0 :(得分:1)

使用.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

您必须自己在NSIS 2中跟踪状态:

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