Archive: how can i do this?


how can i do this?
i have 4 sections,,

section1
section2
section3
section4

section1 is hidden, others are visible

they are in the same group

i want my installer to:

if the user select any section within 2-4, enable section1

if the user does not select any of section[2-4], disable section1

Please tell me how could i do this, thank you


Piece of cake. Assuming you are using Modern UI...


!include Sections.nsh

!define MUI_PAGE_CUSTOMFUNCTION_LEAVE ComponentsLeave
!insertmacro MUI_PAGE_COMPONENTS

...

Section "-section1" Sec1
SectionEnd

Section "section2" Sec2
SectionEnd

Section "section3" Sec3
SectionEnd

Section "section4" Sec4
SectionEnd

Function ComponentsLeave

!insertmacro SectionFlagIsSet ${Sec2} ${SF_SELECTED} SelectSection1 ""
!insertmacro SectionFlagIsSet ${Sec3} ${SF_SELECTED} SelectSection1 ""
!insertmacro SectionFlagIsSet ${Sec4} ${SF_SELECTED} SelectSection1 ""

!insertmacro UnselectSection ${Sec1}

Goto End
SelectSection1:

!insertmacro SelectSection ${Sec1}

End:

FunctionEnd


-Stu

thanks for your help but the code is not working

section1 is visible for testing, section1 is not always enabled when other sections are enabled, and i want auto disable section1 when no other section is enabled


!include Sections.nsh
!include MUI.nsh

!define MUI_PAGE_CUSTOMFUNCTION_LEAVE ComponentsLeave
!insertmacro MUI_PAGE_COMPONENTS
OutFile .\111.exe

Section "section1" Sec1
SectionEnd

Section "section2" Sec2
SectionEnd

Section "section3" Sec3
SectionEnd

Section "section4" Sec4
SectionEnd

Function ComponentsLeave

!insertmacro SectionFlagIsSet ${Sec2} ${SF_SELECTED} SelectSection1 ""
!insertmacro SectionFlagIsSet ${Sec3} ${SF_SELECTED} SelectSection1 ""
!insertmacro SectionFlagIsSet ${Sec4} ${SF_SELECTED} SelectSection1 ""

!insertmacro UnselectSection ${Sec1}

Goto End
SelectSection1:

!insertmacro SelectSection ${Sec1}

End:

FunctionEnd

1. Missing - in front of name in your code. It's in mine.
Section "-section1" Sec1
SectionEnd

2. You need !insertmacro MUI_PAGE_INSTFILES in there otherwise none of the Sections will be executed!

Edit: Oh and btw, when you mean 'disable' and 'enable' are you referring to selecting the section to be executed, or are you referring to enabling the section check-box so that the user can select or unselect it?

-Stu


1. Missing - in front of name in your code. It's in mine.
i deleted the "-" for testing, so i can see the status of the selection,

sorry my english is bad, when i say enable, it means select

i want my secton to look like
http://forums.winamp.com/showthread....hreadid=235097

but section1 is hidden, section2-4 depends on section1
if section2-4 is not selected(checked) auto uncheck section1
that means section1 cannot be installed alone

Oh I see. With the code above Section 1 will be selected if any 1 of the 3 (2-4) Sections are selected. If you need all three selected for Section 1 to be selected, then your ComponentsLeave function should look like this:


Function ComponentsLeave

!insertmacro SectionFlagIsSet ${Sec2} ${SF_SELECTED} 0 UnselectSection1
!insertmacro SectionFlagIsSet ${Sec3} ${SF_SELECTED} 0 UnselectSection1
!insertmacro SectionFlagIsSet ${Sec4} ${SF_SELECTED} SelectSection1 ""

UnselectSection1:

!insertmacro UnselectSection ${Sec1}

Goto End
SelectSection1:

!insertmacro SelectSection ${Sec1}

End:

FunctionEnd


-Stu

thank you
i did it, but i changed something and it worked

!include Sections.nsh

!insertmacro MUI_PAGE_COMPONENTS

...

Section "-section1" Sec1
SectionEnd

Section "section2" Sec2
SectionEnd

Section "section3" Sec3
SectionEnd

Section "section4" Sec4
SectionEnd

Function .onSelChange

!insertmacro SectionFlagIsSet ${Sec2} ${SF_SELECTED} SelectSection1 ""
!insertmacro SectionFlagIsSet ${Sec3} ${SF_SELECTED} SelectSection1 ""
!insertmacro SectionFlagIsSet ${Sec4} ${SF_SELECTED} SelectSection1 ""

!insertmacro UnselectSection ${Sec1}

Goto End
SelectSection1:

!insertmacro SelectSection ${Sec1}

End:

FunctionEnd


I didn't put it in .onSelChange because you won't see the changes made to Sec1 because Sec1 is hidden anyway. Therefore it would be bad coding practice to place the code there which will be called every time the user selects or unselects a section. It might as well be just when the user clicks Next instead...

-Stu


i think nsis should add a manual for section.nsi

or the manual is exist that i cannot find?