!define VER_MAJOR 1
!define VER_MINOR 00
!include CustomPages.nsh

!macro IfSectionChecked sec yes no
  SectionGetFlags "${sec}" $0
  IntOp $0 $0 & 0x80000000
  IntCmpU $0 0x80000000 "${yes}" "${no}" "${no}"
!macroend

Name "TestIT"
Caption "TestIT ${VER_MAJOR}${VER_MINOR}"
OutFile "TestIT ${VER_MAJOR}${VER_MINOR}.exe"
BrandingText "Version 1.1"

ShowInstDetails show

DirText "Dir ..."
InstallDir "C:\"


Function .onInit
  SetOutPath $TEMP
FunctionEnd

!ifdef NSIS_CONFIG_COMPONENTPAGE
ComponentText "Select the server:"
InstType "RTI-Server01"
InstType "RTI-Server02"
InstType "other"
;InstType /COMPONENTSONLYONCUSTOM
InstType /NOCUSTOM
!endif


!insertmacro CustomPages 1245 $R9 $R8 onCustomPage onPageEntry onPageExit

Function onCustomPage
  Exch $0
  ; Show our custom InstOpts pages.
  Push "$TEMP\ini$0.ini"
  CallInstDll "$TEMP\instopts.dll" dialog
  Pop $0
  StrCmp $0 "success" Done
  SetErrors
  StrCmp $0 "back" Done
  ; Something else - abort the installer.
  Call CleanUpAll
  Quit

Done:
  Pop $0
FunctionEnd

Function onPageEntry
  Exch $0
  StrCmp $0 'F' 0 Done
Done:
  StrCmp $0 '4' 0 Done2
Done2:
  Pop $0
FunctionEnd

Function onPageExit
  Exch $0
  ; Abfrage auf Rollouter
    ClearErrors
  Pop $0
FunctionEnd

Function .onUserAbort
  MessageBox MB_YESNO|MB_ICONQUESTION "Are you sure you want to quit the Setup?" IDYES Quiting
    Abort
  Quiting:
FunctionEnd

Function CleanUpAll
  SetDetailsPrint none
  SetDetailsPrint both
FunctionEnd

Section "all"
  MessageBox MB_OK "all"
SectionEnd

Section "Server 01"
  SectionIn 1
  MessageBox MB_OK "RTI 1"
SectionEnd

Section "Server 02"
  SectionIn 2
  MessageBox MB_OK "RTI 2"
SectionEnd

Section "other"
  SectionIn 3
  MessageBox MB_OK "other"
SectionEnd

Section "clean up"
  SectionIn 1 2 3
  MessageBox MB_OK "clean"
  Call CleanUpAll
SectionEnd