Name "SF test"
Outfile "sftest.exe"
ComponentText "Choose what you want to install"

!define SF_SELECTED   1
!define SF_SUBSEC     2
!define SF_SUBSECEND  4
!define SF_BOLD       8
!define SF_RO         16
!define SF_EXPAND     32
!define SECTION_OFF   0xFFFFFFFE

;2.0a7 flags
;!define SECTION_OFF 0x00000000
;!define SF_SELECTED 0x80000000

SubSection "Sections"
Section "section #1" sec1
SectionEnd

Section "section #2" sec2
SectionEnd

Section "section #3" sec3
SectionEnd

SubSectionEnd

SubSection "Additional Sections"

SubSection "subsections of sec1" subsec1
	Section "sub #1-1"
	SectionEnd
	
	Section "sub #1-2"
	SectionEnd
SubSectionEnd

SubSection "subsections of sec2" subsec2
	Section "sub #2-1"
	SectionEnd
SubSectionEnd

SubSectionEnd

Function .onSelChange
	SectionGetFlags ${sec1} $R1
	IntOp $R1 $R1 & ${SF_SELECTED}
	IntCmp $R1 0 0 +2
	SectionSetFlags ${subsec1} ${SECTION_OFF}
	
	SectionGetFlags ${sec2} $R2
	IntOp $R2 $R2 & ${SF_SELECTED}
	IntCmp $R2 0 0 +2
	SectionSetFlags ${subsec2} ${SECTION_OFF}
FunctionEnd