Go to a NSIS page: Difference between revisions
m (FF: use <highlight-nsis> instead of a list. Added "Page author" line. SF: "skiping" -> "skipping".) |
m (I should remind myself to don't close the gap between headers.) |
||
Line 1: | Line 1: | ||
== Description == | == Description == | ||
This function makes NSIS to got to a specified page relatively from the current page. Use it only on normal functions, the ".onUserAbort" callback function (w/o MUI) and the !define MUI_CUSTOMFUNCTION_ABORT "Function" (w/ MUI) (see more information at the bottom of the page). | This function makes NSIS to got to a specified page relatively from the current page. Use it only on normal functions, the ".onUserAbort" callback function (w/o MUI) and the !define MUI_CUSTOMFUNCTION_ABORT "Function" (w/ MUI) (see more information at the bottom of the page). | ||
Line 5: | Line 6: | ||
== Function Call == | == Function Call == | ||
''It doesn't use the stack because changing pages makes the code execution to stop. So instead it uses the variable "$R9".'' | ''It doesn't use the stack because changing pages makes the code execution to stop. So instead it uses the variable "$R9".'' | ||
Line 13: | Line 15: | ||
=== Relative Page Number Values === | === Relative Page Number Values === | ||
*If a number > 0: Goes foward that number of pages. Code of that page will be executed, not returning to this point. If it excess the number of pages that are after that page, it simulates a "Cancel" click. | *If a number > 0: Goes foward that number of pages. Code of that page will be executed, not returning to this point. If it excess the number of pages that are after that page, it simulates a "Cancel" click. | ||
*If a number < 0: Goes back that number of pages. Code of that page will be executed, not returning to this point. If it excess the number of pages that are before that page, it simulates a "Cancel" click. | *If a number < 0: Goes back that number of pages. Code of that page will be executed, not returning to this point. If it excess the number of pages that are before that page, it simulates a "Cancel" click. | ||
Line 19: | Line 22: | ||
== Function Code == | == Function Code == | ||
<highlight-nsis> | <highlight-nsis> | ||
;---------------------------------------------------------------------------- | ;---------------------------------------------------------------------------- | ||
Line 66: | Line 70: | ||
</highlight-nsis> | </highlight-nsis> | ||
== Special Usage - Cancel Clicks Simulation == | == Special Usage - Cancel Clicks Simulation == | ||
The .onUserAbort callback function (w/o MUI) and the function indicated by the !define MUI_CUSTOMFUNCTION_PRE (w/ MUI) totally special in fact that they handle all "Cancel" and "X" clicks the user does, and secondly, that the code still runs if you run the RelGotoPage function, but goes to the page specified after the function is aborted. We can make this "Cancel" and "X" buttons to have a different effect like skipping the next page, by using the following codes: | The .onUserAbort callback function (w/o MUI) and the function indicated by the !define MUI_CUSTOMFUNCTION_PRE (w/ MUI) totally special in fact that they handle all "Cancel" and "X" clicks the user does, and secondly, that the code still runs if you run the RelGotoPage function, but goes to the page specified after the function is aborted. We can make this "Cancel" and "X" buttons to have a different effect like skipping the next page, by using the following codes: | ||
=== For All Pages === | === For All Pages === | ||
==== Default UI ==== | ==== Default UI ==== | ||
Use the normal call that I described on the top of this page but on the function ".onUserAbort": | Use the normal call that I described on the top of this page but on the function ".onUserAbort": | ||
Line 82: | Line 89: | ||
==== Modern UI ==== | ==== Modern UI ==== | ||
Use the normal call that I described on the top of this page on the function indicated by the !define MUI_CUSTOMFUNCTION_ABORT: | Use the normal call that I described on the top of this page on the function indicated by the !define MUI_CUSTOMFUNCTION_ABORT: | ||
Line 99: | Line 107: | ||
=== For One Page === | === For One Page === | ||
==== Default UI ==== | ==== Default UI ==== | ||
Use a variable to hold the page index inside the PreFunction of every page and before InstallOptions plugin first call inside every custom page main function, and compare this variable inside the ".onUserAbort" callback function. An example: | Use a variable to hold the page index inside the PreFunction of every page and before InstallOptions plugin first call inside every custom page main function, and compare this variable inside the ".onUserAbort" callback function. An example: | ||
Line 132: | Line 142: | ||
==== Modern UI ==== | ==== Modern UI ==== | ||
Use a variable to hold the page index inside the function indicated by each !define MUI_PAGE_CUSTOMFUNCTION_PRE of every page and before MUI_INSTALLOPTIONS_* macro first call inside every custom page main function (except for MUI_INSTALLOPTIONS_READ and MUI_INSTALLOPTIONS_WRITE macros), and compare this variable inside the function indicated by the !define MUI_CUSTOMFUNCTION_ABORT. An example: | Use a variable to hold the page index inside the function indicated by each !define MUI_PAGE_CUSTOMFUNCTION_PRE of every page and before MUI_INSTALLOPTIONS_* macro first call inside every custom page main function (except for MUI_INSTALLOPTIONS_READ and MUI_INSTALLOPTIONS_WRITE macros), and compare this variable inside the function indicated by the !define MUI_CUSTOMFUNCTION_ABORT. An example: | ||
Revision as of 20:21, 29 April 2005
Description
This function makes NSIS to got to a specified page relatively from the current page. Use it only on normal functions, the ".onUserAbort" callback function (w/o MUI) and the !define MUI_CUSTOMFUNCTION_ABORT "Function" (w/ MUI) (see more information at the bottom of the page).
This function also allow InstallOptions and InstallOptionsEx to use its features so you can choose which controls will take the place of the default NSIS buttons.
Function Call
It doesn't use the stack because changing pages makes the code execution to stop. So instead it uses the variable "$R9".
StrCpy $R9 "(number|X)" ;Relative page number. See below. Call RelGotoPage
Relative Page Number Values
- If a number > 0: Goes foward that number of pages. Code of that page will be executed, not returning to this point. If it excess the number of pages that are after that page, it simulates a "Cancel" click.
- If a number < 0: Goes back that number of pages. Code of that page will be executed, not returning to this point. If it excess the number of pages that are before that page, it simulates a "Cancel" click.
- If X: Simulates a "Cancel" click. Code will go to callback functions, not returning to this point.
- If 0: Continues on the same page. Code will still be running after the call.
Function Code
;---------------------------------------------------------------------------- ; Title : Go to a NSIS page ; Short Name : RelGotoPage ; Last Changed : 22/Feb/2005 ; Code Type : Function ; Code Sub-Type : Special Restricted Call, One-way StrCpy Input ;---------------------------------------------------------------------------- ; Description : Makes NSIS to go to a specified page relatively from ; the current page. See this below for more information: ; "http://nsis.sourceforge.net/archive/nsisweb.php?page=705&instances=0,11" ;---------------------------------------------------------------------------- ; Function Call : StrCpy $R9 "(number|X)" ; ; - If a number > 0: Goes foward that number of ; pages. Code of that page will be executed, not ; returning to this point. If it excess the number of ; pages that are after that page, it simulates a ; "Cancel" click. ; ; - If a number < 0: Goes back that number of pages. ; Code of that page will be executed, not returning to ; this point. If it excess the number of pages that ; are before that page, it simulates a "Cancel" click. ; ; - If X: Simulates a "Cancel" click. Code will go to ; callback functions, not returning to this point. ; ; - If 0: Continues on the same page. Code will still ; be running after the call. ; ; Call RelGotoPage ;---------------------------------------------------------------------------- ; Author : Diego Pedroso ; Author Reg. Name : deguix ;---------------------------------------------------------------------------- Function RelGotoPage IntCmp $R9 0 0 Move Move StrCmp $R9 "X" 0 Move StrCpy $R9 "120" Move: SendMessage $HWNDPARENT "0x408" "$R9" "" FunctionEnd
Special Usage - Cancel Clicks Simulation
The .onUserAbort callback function (w/o MUI) and the function indicated by the !define MUI_CUSTOMFUNCTION_PRE (w/ MUI) totally special in fact that they handle all "Cancel" and "X" clicks the user does, and secondly, that the code still runs if you run the RelGotoPage function, but goes to the page specified after the function is aborted. We can make this "Cancel" and "X" buttons to have a different effect like skipping the next page, by using the following codes:
For All Pages
Default UI
Use the normal call that I described on the top of this page but on the function ".onUserAbort":
Function .onUserAbort StrCpy $R9 1 ;Goto the next page Call RelGotoPage Abort FunctionEnd
Modern UI
Use the normal call that I described on the top of this page on the function indicated by the !define MUI_CUSTOMFUNCTION_ABORT:
!insert "MUI.nsh" ;Required by MUI !define MUI_CUSTOMFUNCTION_ABORT "FunctionName" !insertmacro MUI_LANGUAGE "English" ;Required by MUI Function FunctionName StrCpy $R9 1 ;Goto the next page Call RelGotoPage Abort FunctionEnd
For One Page
Default UI
Use a variable to hold the page index inside the PreFunction of every page and before InstallOptions plugin first call inside every custom page main function, and compare this variable inside the ".onUserAbort" callback function. An example:
Page custom CustomPage Page components Components_PreFunction Page directory Directory_PreFunction Function CustomPage StrCpy $R8 1 ;This is the first page InstallOptions::dialog "C:\MyDir\MyIOPage.ini" Pop $0 FunctionEnd Function Components_PreFunction StrCpy $R8 2 ;This is the second page FunctionEnd Function Directory_PreFunction StrCpy $R8 3 ;This is the third page FunctionEnd Function .onUserAbort StrCmp $R8 1 0 End ;Compare the variable with the ;page index of your choice StrCpy $R9 1 Call RelGotoPage Abort End: FunctionEnd
Modern UI
Use a variable to hold the page index inside the function indicated by each !define MUI_PAGE_CUSTOMFUNCTION_PRE of every page and before MUI_INSTALLOPTIONS_* macro first call inside every custom page main function (except for MUI_INSTALLOPTIONS_READ and MUI_INSTALLOPTIONS_WRITE macros), and compare this variable inside the function indicated by the !define MUI_CUSTOMFUNCTION_ABORT. An example:
!include "MUI.nsh" ;Required by MUI Page custom CustomPage !define MUI_PAGE_CUSTOMFUNCTION_PRE Components_PreFunction !insertmacro MUI_PAGE_COMPONENTS !define MUI_PAGE_CUSTOMFUNCTION_PRE Directory_PreFunction !insertmacro MUI_PAGE_DIRECTORY !define MUI_CUSTOMFUNCTION_ABORT "FunctionName" !insertmacro MUI_LANGUAGE "English" ;Required by MUI Function CustomPage StrCpy $R8 1 ;This is the first page InstallOptions::dialog "C:\MyDir\MyIOPage.ini" Pop $0 FunctionEnd Function Components_PreFunction StrCpy $R8 2 ;This is the second page FunctionEnd Function Directory_PreFunction StrCpy $R8 3 ;This is the third page FunctionEnd Function FunctionName StrCmp $R8 1 0 End ;Compare the variable with the ;page index of your choice StrCpy $R9 1 Call RelGotoPage Abort End: FunctionEnd
Page author: deguix