Go to a NSIS page: Difference between revisions
(Created page.) |
m (FF: use <highlight-nsis> instead of a list. Added "Page author" line. SF: "skiping" -> "skipping".) |
||
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 6: | Line 5: | ||
== 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".'' | ||
<highlight-nsis> | |||
StrCpy $R9 "(number|X)" ;Relative page number. See below. | |||
< | Call RelGotoPage | ||
</highlight-nsis> | |||
=== 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 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 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. | *If 0: Continues on the same page. Code will still be running after the call. | ||
== Function Code == | == Function Code == | ||
<highlight-nsis> | |||
<highlight-nsis>;---------------------------------------------------------------------------- | ;---------------------------------------------------------------------------- | ||
; Title : Go to a NSIS page | ; Title : Go to a NSIS page | ||
; Short Name : RelGotoPage | ; Short Name : RelGotoPage | ||
Line 68: | Line 63: | ||
Move: | Move: | ||
SendMessage $HWNDPARENT "0x408" "$R9" "" | SendMessage $HWNDPARENT "0x408" "$R9" "" | ||
FunctionEnd</highlight-nsis> | FunctionEnd | ||
</highlight-nsis> | |||
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 | == 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 === | === 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": | ||
<highlight-nsis>Function .onUserAbort | <highlight-nsis> | ||
Function .onUserAbort | |||
StrCpy $R9 1 ;Goto the next page | StrCpy $R9 1 ;Goto the next page | ||
Call RelGotoPage | Call RelGotoPage | ||
Abort | Abort | ||
FunctionEnd</highlight-nsis> | FunctionEnd | ||
</highlight-nsis> | |||
==== 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: | ||
<highlight-nsis>!insert "MUI.nsh" ;Required by MUI | <highlight-nsis> | ||
!insert "MUI.nsh" ;Required by MUI | |||
!define MUI_CUSTOMFUNCTION_ABORT "FunctionName" | !define MUI_CUSTOMFUNCTION_ABORT "FunctionName" | ||
Line 100: | Line 95: | ||
Call RelGotoPage | Call RelGotoPage | ||
Abort | Abort | ||
FunctionEnd</highlight-nsis> | FunctionEnd | ||
</highlight-nsis> | |||
=== 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: | ||
<highlight-nsis>Page custom CustomPage | <highlight-nsis> | ||
Page custom CustomPage | |||
Page components Components_PreFunction | Page components Components_PreFunction | ||
Page directory Directory_PreFunction | Page directory Directory_PreFunction | ||
Line 133: | Line 128: | ||
Abort | Abort | ||
End: | End: | ||
FunctionEnd</highlight-nsis> | FunctionEnd | ||
</highlight-nsis> | |||
==== 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: | ||
<highlight-nsis>!include "MUI.nsh" ;Required by MUI | <highlight-nsis> | ||
!include "MUI.nsh" ;Required by MUI | |||
Page custom CustomPage | Page custom CustomPage | ||
Line 171: | Line 167: | ||
Abort | Abort | ||
End: | End: | ||
FunctionEnd</highlight-nsis> | FunctionEnd | ||
</highlight-nsis> | |||
Page author: [[User:deguix|deguix]] |
Revision as of 20:19, 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