我如何仅禁用某个InstType中的某个部分,否则强制它(即使在“自定义”InstType中)?

时间:2012-01-06 14:12:58

标签: nsis

我的Section设置为RO,并且除了特殊的InstType外,所有InstType都会出现。{/ p>

当用户首先选择特殊InstType,然后选择“自定义”作为InstType时,该部分将被取消选中,并且无法在“自定义”InstType中再次检查。

所以一切都很好,但当用户选择“自定义”Section时,应始终再次检查InstType

只有在特殊{{1}}用例中才应取消选中。

我怎样才能做到这一点?

1 个答案:

答案 0 :(得分:1)

您可以在.onSelChange中强制执行您想要的任何逻辑:

!include WinMessages.nsh
!include LogicLib.nsh
!include Sections.nsh

Page Components
Page InstFiles

InstType "Normal1"
!define CIT_Special 1
InstType "Special"
InstType "Normal2"

Section Foo
SectionIn 1 2 3
SectionEnd

Section Bar SEC_Special
SectionIn 1 3
SectionIn RO
SectionEnd

Section Baz
SectionIn 1 2 ;3 << Not the same as Foo just to have some sort of difference
SectionEnd

Function .onSelChange
;Normally you would call GetCurInstType here, but it seems we need a little hack to detect the custom section
FindWindow $1 "#32770" "" $HWNDPARENT
GetDlgItem $1 $1 0x3F9
SendMessage $1 ${CB_GETCURSEL} 0 0 $2
SendMessage $1 ${CB_GETITEMDATA} $2 0 $2
${If} $2 = ${CIT_Special}
    !insertmacro UnselectSection ${SEC_Special}
${Else}
    !insertmacro SelectSection ${SEC_Special}
${EndIf}
FunctionEnd