Archive: Unselect a subsection


Unselect a subsection
I've searched across the examples on NSIS website and trough this forum and I have not seen any example of code that let the user unselect a subsection.

In all the examples that I have seen, the subsection checkbox is grey. My question is: Is there any way to make a subsection unselectable ?


You need to do exactly the same as with Sections:

SubSection "My Sub Section" SubSec1
### blah ###
SubSectionEnd

Now, you need to put this code in the .oninit function.

!define SECTION_OFF 0xFFFFFFFE ## define once

## Place in oninit
Push $R0
SectionGetFlags ${SubSec1} $R0
IntOP $R0 $R0 & ${SECTION_OFF}
SectionSetFlags ${SubSec1} $R0
Pop $R0

This should work, unless it works differently with subsections?

-Stu


Thanks very much for your answer, I'm gonna try it and tell you if it works =).


It has worked perfectly, but I had to add this value defined in sections.nsh:


!define SF_SUBSECEND 4

(just add an include)


which defines that this particular item is a subsection (if you don't all the subsections become sections).

I also saw your example in the tutorials on the NSIS website, and I found some sample containing this code in another example:



!ifdef USE_SUBSECTION
; Check if the user have selected all of the sections using the sub-section
Push $2
StrCpy $2 ${SF_SELECTED}
SectionGetFlags ${sec1} $0
IntOp $2 $2 & $0
SectionGetFlags ${sec2} $0
IntOp $2 $2 & $0
SectionGetFlags ${sec3} $0
IntOp $2 $2 & $0
SectionGetFlags ${sec4} $0
IntOp $2 $2 & $0
StrCmp $2 0 skip
SectionSetFlags ${sec1} 0
SectionSetFlags ${sec2} 0
SectionSetFlags ${sec3} 0
SectionSetFlags ${sec4} 0
skip:
Pop $2
!endif


It makes that when you click on the top section the values in subsections are not changed (without this, when you click on top section, all the subs go fuzzy).

This should be included in Sections.nsh

I will notify Kichik

-Stu


This piece of code was taken from one-section.nsi. It can't be in sections.nsh because it's not abstract enough.

I have updated one-section.nsi to make this test a bit more efficient and use some of the latest changes. You should take a look if controlling sub-sections is what you're after.