Skip to content
⌘ NSIS Forum Archive

Return to a custom page

3 posts

LordDaimos#

Return to a custom page

I have an installer project with two custom pages using InstallOptions. I've gotten it to work pretty well and as satisfied with it but I'm still having one last problem with it. When I go from the first custom page to the next and then press the back button it skips to the page before my first custom page. ie it goes from page three to page one in a single click where I would want it to go to page two.

This is the code for page two
Function ServicePage
  ; Check if SEC01 is selected, if not then abort
  SectionGetFlags ${SEC01} $R0
  IntOp $R0 $R0 & ${SF_SELECTED}
  IntCmp $R0 ${SF_SELECTED} ShowServicePage
  Abort
  ShowServicePage:
  !insertmacro MUI_HEADER_TEXT "Service account setup" "Specify the username and password for the account that the service should run as"
  !insertmacro MUI_INSTALLOPTIONS_EXTRACT "ServiceDialog.ini"
  !insertmacro MUI_INSTALLOPTIONS_DISPLAY "ServiceDialog.ini"
FunctionEnd
!macro EnableField IniFilename SectionName Enable
  Push $R0
  !insertmacro MUI_INSTALLOPTIONS_READ $R0 "${IniFilename}" "${SectionName}" "HWND"
  EnableWindow $R0 ${Enable}
  Pop $R0
!macroend
Function ServicePageLeave
  !insertmacro MUI_INSTALLOPTIONS_READ $0 "ServiceDialog.ini" "Settings" "State"
  IntCmp $0 1 0 NextCheck NextCheck
  !insertmacro EnableField "ServiceDialog.ini" "Field 3" 0
  !insertmacro EnableField "ServiceDialog.ini" "Field 4" 0
  !insertmacro EnableField "ServiceDialog.ini" "Field 5" 0
  Abort
  NextCheck:
  IntCmp $0 2 0 FinishServicePage FinishServicePage
  !insertmacro EnableField "ServiceDialog.ini" "Field 3" 1
  !insertmacro EnableField "ServiceDialog.ini" "Field 4" 1
  !insertmacro EnableField "ServiceDialog.ini" "Field 5" 1
  Abort
  
  FinishServicePage:
  !insertmacro MUI_INSTALLOPTIONS_READ $0 "ServiceDialog.ini" "Field 1" "State"
  IntCmp $0 1 SystemAccount
  !insertmacro MUI_INSTALLOPTIONS_READ $SERVICEUSER "ServiceDialog.ini" "Field 2" "State"
  !insertmacro MUI_INSTALLOPTIONS_READ $SERVICEPASSWORD "ServiceDialog.ini" "Field 4" "State"
  !insertmacro MUI_INSTALLOPTIONS_READ $0 "ServiceDialog.ini" "Field 4" "State"
  StrCmp $SERVICEPASSWORD $0 0 FinishServicePageEnd
  Messagebox MB_ICONEXCLAMATION|MB_OK "The input password doesn't match"
  Abort
  SystemAccount:
  StrCpy $SERVICEUSER ""
  StrCpy $SERVICEPASSWORD ""
  
  FinishServicePageEnd:
  Delete "$Pluginsdir\ServiceDialog.ini"
FunctionEnd 
This is the code for page three
Function DatabasePage
  ; Check if SEC02 is selected, if not then abort
  SectionGetFlags ${SEC02} $R0
  IntOp $R0 $R0 & ${SF_SELECTED}
  IntCmp $R0 ${SF_SELECTED} ShowDatabasePage
  Abort
  ShowDatabasePage:
  ReserveFile "SQLDialog.ini"
  !insertmacro MUI_HEADER_TEXT "Database setup" "Specify the necessary parameters to connect to the database"
  !insertmacro MUI_INSTALLOPTIONS_EXTRACT "SQLDialog.ini"
  !insertmacro MUI_INSTALLOPTIONS_DISPLAY "SQLDialog.ini"
FunctionEnd
Function DatabasePageLeave
  !insertmacro MUI_INSTALLOPTIONS_READ $SQLSERVER "SQLDialog.ini" "Field 2" "State"
  !insertmacro MUI_INSTALLOPTIONS_READ $SQLUSER "SQLDialog.ini" "Field 4" "State"
  !insertmacro MUI_INSTALLOPTIONS_READ $SQLPASSWORD "SQLDialog.ini" "Field 7" "State"
  !insertmacro MUI_INSTALLOPTIONS_READ $SQLDATABASE "SQLDialog.ini" "Field 8" "State"
  Delete "$TEMP\SQLDialog.ini"
FunctionEnd 
Anyone having any ideas why this happens?

/ Karl
Afrow UK#
Put a MessageBox before the Abort in Function ServicePage and see if you get the message when you click back. If so then it must be calling Abort and jumping over the page.

Also you may want to move your MUI_INSTALLOPTIONS_EXTRACT insertmacros to .onInit as when you do click back and then forward again to the same page you will lose what you had entered/selected previously because the INI file will have been overwritten.

Stu
LordDaimos#
Problem solved, I moved the deleting of the .ini-files to -Post and the extraction to .onInit and it started to work as expected! Thanks!

/ Karl