mdrayner
12th April 2005 19:48 UTC
2 sections, allow one at a time only
I have an installer set up with 3 sections.
1 is hidden so that it always installs but the others need to be optional.
Is there a way that I can make only 1 section selectable at a time and not allow them to progress without selecting one.?
Thanks
Mike
Jnuw
12th April 2005 20:51 UTC
From the one-section.nsi in the examples folder:
;add at the top add
!include "Sections.nsh"
;add by all your functions
Function .onSelChange
!insertmacro StartRadioButtons $1
!insertmacro RadioButton ${SEC01}
!insertmacro RadioButton ${SEC02}
!insertmacro EndRadioButtons
FunctionEnd
Just make sure your sections are marked like this:
Section /O "Section 1" SEC01
Section /O "Section 2" SEC02
...this should make the user only be able to check one or the other section, but not both.
As for ensureing at least one section is checked, add:
;the below line here...
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE "ComponentsLeave"
!insertmacro MUI_PAGE_COMPONENTS
;and this function...
Function ComponentsLeave
SectionGetFlags "${SEC01}" $0
StrCmp $0 1 End
SectionGetFlags "${SEC02}" $0
StrCmp $0 1 End
MessageBox MB_OK|MB_ICONINFORMATION "You must select at least one section."
Abort
End:
FunctionEnd
Hope this helps.
kichik
12th April 2005 20:57 UTC
Take a look at Examples\one-section.nsi. It sets a similar restriction. Also search the forum, there were plenty of threads with similar problems and scripts to solve them. The Archive or the Wiki probably contain some useful scripts too.
[edit] Or use what Junw posted above.