Skip to content
⌘ NSIS Forum Archive

Custom + Cancel button

4 posts

kallan06#

Custom + Cancel button

Hi all 🙂 !

I've little problem with page custom.

When click on "Cancel" button, the installer not cancel but execute custom function.
click on cancel -> call SerialPageLeave

!insertmacro XPUI_PAGE_WELCOME
Page custom SerialPageShow SerialPageLeave
!insertmacro XPUI_PAGE_FINISH
!insertmacro XPUI_PAGE_ABORT
;-----------------------------------------
  # uninstall pages    
  # paste all pages in uninstall mode
!insertmacro XPUI_PAGEMODE_UNINST
!insertmacro XPUI_PAGE_INSTCONFIRM
!insertmacro XPUI_PAGE_FINISH
!insertmacro XPUI_PAGE_ABORT
;-----------------------------------------
  #Langue selection -> can add other language Deutch, spannish...
!insertmacro XPUI_LANGUAGE "English"
!insertmacro XPUI_LANGUAGE "French"
;-----------------------------------------
  #Reserve files
ReserveFile "DTandQL.ini"
ReserveFile "upgrade.ini"
ReserveFile "serial.ini"
;-----------------------------------------
.................
.................
    
;--------------------------------
;Reserve Files
  
Section  Sec
.........
SectionEnd
;****************************************************************************
;                                                     CallBack - Function(s)
Function .onInit
SetOutPath "$PLUGINSDIR"
;Modeless banner sample: show + wait
File ${IMG_NAME}
newadvsplash::show /NOUNLOAD 2000 500 500 0x0666666 /BANNER "$PLUGINSDIR\${IMG_NAME}"
FunctionEnd
Function un.onInit
    
FunctionEnd
;****************************************************************************
;                                                               Uninstall
Section Uninstall
    
...........
...........
    
SectionEnd
    
;****************************************************************************
;                                                                Function(s)
## Displays the serial dialog
Function SerialPageShow
!insertmacro MUI_INSTALLOPTIONS_EXTRACT "serial.ini"
!insertmacro MUI_HEADER_TEXT "$(SERIAL_TITLETEXT_1)" "$(SERIAL_TITLETEXT_2)"
!insertmacro MUI_INSTALLOPTIONS_WRITE "serial.ini" "Field 1" "Text" "$(SERIAL_TEXT)"
!insertmacro MUI_INSTALLOPTIONS_WRITE "serial.ini" "Field 11" "Text" "$(VALIDESERIAL_BT)"
  !insertmacro MUI_INSTALLOPTIONS_DISPLAY "serial.ini"
  Pop $R0 # success, back, cancel or error
FunctionEnd
Function SerialPageLeave
Pop $4
Pop $5
Pop $6
Pop $7
Pop $8
ReadINIStr $4 "$PLUGINSDIRserial.ini" "Field 2" "State"
ReadINIStr $5 "$PLUGINSDIRserial.ini" "Field 3" "State"
ReadINIStr $6 "$PLUGINSDIRserial.ini" "Field 4" "State"
ReadINIStr $7 "$PLUGINSDIRserial.ini" "Field 5" "State"
ReadINIStr $8 "$PLUGINSDIRserial.ini" "Field 6" "State"
## A bit of validation
StrCpy '$9' '$4-$5-$6-$7-$8'
MessageBox MB_OK '$9'
# initialisation for 501 value
StrCmp $9 aaaa-aaaa-aaaa-aaaa-aaaa Good
StrCmp $9 aaaa-aaaa-aaaa-aaaa-bbbb Good
StrCmp $9 aaaa-aaaa-aaaa-aaaa-bbbb Good
Bad:
MessageBox MB_OK|MB_ICONEXCLAMATION "$(INVALID_SERIAL)"
Abort
Good:
FunctionEnd 
kallan06#
Hey,
thx for you help.

I've last question ! how can one leave the setup? i.e. if my popup appears and that I validate, all the setup is closed?
(Ok on popup.png)