i'm attempting create installer asks user series of questions decide components install. each choice (potentially) influences available options in later choices (else normal components page—i don't want give user invalid options).
how accomplish such thing? if use components page, options shown, combinations of invalid. don't want let user select those. is possible leave out components page?
here's minimal working example of i'm trying. (sorry it's long, couldn't simplify dialog code.)
!include nsdialogs.nsh !include sections.nsh name "mwe" outfile "mwe.exe" installdir c:\mwe var hwnd var level1opt page custom selectlevel1opt processlevel1 function selectlevel1opt nsdialogs::create 1018 pop $hwnd ${nsd_createlabel} 0 0 100% 12u "please select level 1 option" pop $hwnd ${nsd_createradiobutton} 10% 12u 100% 12u "level 1 a" pop $hwnd nsdialogs::setuserdata $hwnd "level 1 a" ${nsd_onclick} $hwnd setlevel1 ${nsd_createradiobutton} 10% 24u 100% 12u "level 1 b" pop $hwnd nsdialogs::setuserdata $hwnd "level 1 b" ${nsd_onclick} $hwnd setlevel1 nsdialogs::show functionend function setlevel1 pop $hwnd nsdialogs::getuserdata $hwnd pop $level1opt messagebox mb_ok "selected: $level1opt" functionend function processlevel1 ${if} $level1opt == "level 1 a" !insertmacro selectsection level1a ${elseif} $level1opt == "level 1 b" !insertmacro selectsection level1b ${endif} functionend page directory page instfiles section "" messagebox mb_ok "common install" sectionend section /o "" level1a messagebox mb_ok "level 1 a" sectionend section /o "" level1b messagebox mb_ok "level 1 b" sectionend
no matter choose, neither level1a
nor level1b
sections run. selection dialog correctly detected in handler , post function. however, selecting sections isn't causing them run. if add components page, neither of them selected.
i looked in selection.nsh
, , example refers (one-section.nsi) doesn't want, because uses components page. (i don't understand quite how works.)
what doing wrong? in way misunderstanding way nsis supposed work?
as idleberg says, correct syntax !insertmacro selectsection ${level1a}
warning because section id not defined until after section
instruction in .nsi. need move functions use ${level1a}
below sections in source code:
!include nsdialogs.nsh !include sections.nsh page custom selectlevel1opt processlevel1 page instfiles section "" messagebox mb_ok "common install" sectionend section /o "a" level1a messagebox mb_ok "level 1 a" sectionend section /o "b" level1b messagebox mb_ok "level 1 b" sectionend var hinnerdialog var hl1a var hl1b function selectlevel1opt nsdialogs::create 1018 pop $hinnerdialog ${nsd_createlabel} 0 0 100% 12u "please select level 1 option" pop $0 ${nsd_createradiobutton} 10% 12u 100% 12u "level 1 a" pop $hl1a nsdialogs::setuserdata $hl1a ${level1a} ; used generic function ${nsd_createradiobutton} 10% 24u 100% 12u "level 1 b" pop $hl1b nsdialogs::setuserdata $hl1b ${level1b} ; used generic function nsdialogs::show functionend function processlevel1 ${nsd_getstate} $hl1a $1 ${if} $1 <> ${bst_unchecked} !insertmacro selectsection ${level1a} !insertmacro unselectsection ${level1b} ${else} !insertmacro selectsection ${level1b} !insertmacro unselectsection ${level1a} ${endif} functionend
the processlevel1 function can implemented loop if there many radio buttons:
function processlevel1 strcpy $0 "" loop: findwindow $0 "${__nsd_radiobutton_class}" "" $hinnerdialog $0 system::call "user32::getwindowlong(p$0,i${gwl_style})i.r1" intop $1 $1 & ${bs_autoradiobutton} ${if} $1 = ${bs_autoradiobutton} ; auto radio button? nsdialogs::getuserdata $0 ; section id pop $2 ${nsd_getstate} $0 $1 ${if} $1 <> ${bst_unchecked} !insertmacro selectsection $2 ${else} !insertmacro unselectsection $2 ${endif} ${endif} intcmp $0 0 "" loop loop functionend