Go to a NSIS page: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
m (FF: use <highlight-nsis> instead of a list. Added "Page author" line. SF: "skiping" -> "skipping".)
m (Reverted edits by 84.228.86.84 to last version by Kichik)
 
(9 intermediate revisions by 5 users not shown)
Line 1: Line 1:
{{PageAuthor|deguix}}
== 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 also allow InstallOptions and InstallOptionsEx to use its features so you can choose which controls will take the place of the default NSIS buttons.
This function makes NSIS to go to a specified page relatively from the current page. Use it only on normal functions, the ".onUserAbort" callback function (w/o MUI) or the !define MUI_CUSTOMFUNCTION_ABORT "Function" (w/ MUI) (see more information at the bottom of the page).
 
This function also allows InstallOptions and InstallOptionsEx to use its features so you can choose which controls will take the place of the default NSIS buttons.


== 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 17:


=== Relative Page Number Values ===
=== Relative Page Number Values ===
*If a number &gt; 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 &lt; 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 &gt; 0: Goes foward that number of pages. Code of that page will be executed, not returning to this point. If it is bigger than the number of pages that are after that page, it simulates a "Cancel" click.
*If a number &lt; 0: Goes back that number of pages. Code of that page will be executed, not returning to this point. If it is bigger than 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>
;----------------------------------------------------------------------------
;----------------------------------------------------------------------------
Line 29: Line 35:
; Description      : Makes NSIS to go to a specified page relatively from
; Description      : Makes NSIS to go to a specified page relatively from
;                    the current page. See this below for more information:
;                    the current page. See this below for more information:
;   "http://nsis.sourceforge.net/archive/nsisweb.php?page=705&instances=0,11"
;                     "http://nsis.sf.net/wiki/Go to a NSIS page"
;----------------------------------------------------------------------------
;----------------------------------------------------------------------------
; Function Call    : StrCpy $R9 "(number|X)"
; Function Call    : StrCpy $R9 "(number|X)"
Line 66: Line 72:
</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) are 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 to 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 91:


==== 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 109:


=== 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 144:


==== 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:


Line 170: Line 183:
</highlight-nsis>
</highlight-nsis>


Page author: [[User:deguix|deguix]]
[[Category:User Interface Functions]]

Latest revision as of 22:11, 8 November 2005

Author: deguix (talk, contrib)


Description

This function makes NSIS to go to a specified page relatively from the current page. Use it only on normal functions, the ".onUserAbort" callback function (w/o MUI) or the !define MUI_CUSTOMFUNCTION_ABORT "Function" (w/ MUI) (see more information at the bottom of the page).

This function also allows 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 is bigger than 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 is bigger than 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.sf.net/wiki/Go to a NSIS page"
;----------------------------------------------------------------------------
; Function Call     : StrCpy $R9 "(number|X)"
;
;                     - If a number &gt; 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 &lt; 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) are 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 to 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