MSG
11th January 2010 11:24 UTC
Jumping to a conditional page
From my first page's SHOW function I jump six pages forward, into a custom nsDialogs page. This custom page is a conditional one. Like this:
Function MyCustomPage
${If} $MyVar == "ShowThePage"
nsDialogs::Create 1018
Pop $2
nsDialogs::Show
${EndIf}
FunctionEnd
In the case that the page is NOT shown, the installer crashes. How can I jump into this conditional page properly?
(Note: Adding an ${Else} statement with a 'skip to next page' command is not a solution, because in that case you can't go Back from the following page.)
jpderuiter
11th January 2010 11:37 UTC
Maybe this helps?
http://nsis.sourceforge.net/Go_to_a_NSIS_page
I'm not sure if this will help you with the Back button.
Maybe you have to make your own Back button code.
MSG
11th January 2010 11:40 UTC
Like I said I'm jumping six pages ahead, so obviously I'm already using that code... :rolleyes: The problem lies in jumping forward into a conditional page.
(Edit: Since the page after all this is another nsDialogs page, I can use nsDialogs::OnBack to solve my problem. But IIRC there's no OnBack callback for default pages, is there?)
MSG
11th January 2010 20:19 UTC
I think I've got it working... My solution: Using the ${Else} GotoNextPage clause, but only if the previously visited page was before MyCustomPage.
!define PAGE_NUMBER_MyCustomPage 7
Function MyCustomPage
${If} $MyVar == "ShowThePage"
nsDialogs::Create 1018
Pop $2
StrCpy $PREVIOUSPAGE ${PAGE_NUMBER_MyCustomPage}
nsDialogs::Show
${ElseIf} $PREVIOUSPAGE < ${PAGE_NUMBER_MyCustomPage}
StrCpy $PREVIOUSPAGE ${PAGE_NUMBER_MyCustomPage}
SendMessage $HWNDPARENT "0x408" "1" ""
${EndIf}
FunctionEnd
And then of course updating $PREVIOUSPAGE in every page, just before I leave it.
After the installer jumps forward six pages, the ${ElseIf} statement will force it to go forward one more. (Of course the next page should always be shown. If it's another conditional page, I guess you'd need to make it jump forward yet again in the ${Else} case.) This way, the installer will always reach a real page that it can actually draw, preventing it from crashing.
Naturally if the user clicks the Back button the ${ElseIf} statement will not be true, and there will again not be any page to draw. But this is no problem because the installer will then just go back yet another page. The crash only occurs when
manually jumping pages using SendMessage.