Reputation: 834
I'm writing an install script utilizing the NSIS installer scripting language. I have a few custom pages that I am able to load without hassle, but I was wondering if it would be possible to insert pages dynamically. What I want to do is have a page with additional configuration options on it and on the bottom have a checkbox that says "Add more settings" or something similar. If the checkbox is ticked, it will show another custom page that's an exact copy of the first one. As long as the user keeps checking the checkbox, more pages should be shown. Is there some method of recycling the same page over and over again? I really don't think I should need to generate a whole new page because it's just the same page again and again, but I'm not sure how to show a new instance of the same page during runtime. A quick Google and stackoverflow search did not warrant any results.
Thanks guys.
Upvotes: 2
Views: 410
Reputation: 111
page custom page1 option
page instfiles
Function page1
initpluginsdir
file /oname=$PLUGINSDIR\dlg.ini dlg.ini
installoptions::dialog "$PLUGINSDIR\dlg.ini"
FunctionEnd
Function Options
ReadINIStr $0 "$PLUGINSDIR\dlg.ini" "Field 1" "State" # Field Must have value 0 or 1. Maybe Text or Chechbox
StrCmp $0 0 0 +2
abort
FunctionEnd
Upvotes: 0
Reputation: 101569
The number of pages is fixed at compile time.
If you need different "hidden" pages or just a couple instances of the same page I would say that you should just skip the pages when required in the create callback for the page by calling abort but this is not going to work if the page count is unlimited.
It is also possible to go directly to a page:
Outfile test.exe
Requestexecutionlevel user
!include nsDialogs.nsh
Page Custom mypagecreate mypageleave
Page Directory dirpagecreate
Page Instfiles
Function mypagecreate
Var /Global MyCheckBox
nsDialogs::Create /NOUNLOAD 1018
Pop $0
${NSD_CreateCheckBox} 10% 20u 80% 12u "Again?"
Pop $MyCheckBox
nsDialogs::Show
FunctionEnd
Function mypageleave
${NSD_GetState} $MyCheckBox $0
StrCpy $MyCheckBox $0 ; This is a bit of a hack, we reuse the HWND var to store the state
FunctionEnd
Function dirpagecreate
${If} $MyCheckBox <> 0 ; Was the checkbox checked?
SendMessage $HWNDPARENT 0x408 -1 "" ; If so, go back
${EndIf}
FunctionEnd
Section
SectionEnd
Upvotes: 1