Archive: Custom screen and cancel button


Custom screen and cancel button
Hi,

I've created a custom screen with some input fields that are saved to an .ini file. That works great, but when I press the CANCEL button on this custom screen the values are written to the .ini file!


Function SettingsPage

# Display the page.
!insertmacro MUI_INSTALLOPTIONS_DISPLAY "screen1.ini"

!insertmacro MUI_INSTALLOPTIONS_READ $Username "screen1.ini" "Field 1" "State"

WriteINIStr "$INSTDIR\settings.ini" "settings" "username" "$Username"

FunctionEnd

Also, how is it possible to check if the fields are filled in? If not, show a message dialog that they must be filled in. And when a FileRequest/DirRequest is used, if the file/dir exists? (if they don't use the chooser)

Thanks for the time/help.

you can do this using MinLen/MaxLen or notify flags. check the docs for details.


Originally posted by Yathosho
you can do this using MinLen/MaxLen or notify flags. check the docs for details.
Great, thanks for the help.
To see if the user press cancel in the custom screen I now use this:

!insertmacro MUI_INSTALLOPTIONS_DISPLAY "screen1.ini"
Pop $R0 ;Get the return value
StrCmp $R0 "success" +3
Call SaveINI

But for some strange reason the result is always "success", even when I press cancel!?

From the MUI ReadMe:

If you need the InstallOptions return value (success, back, cancel, error), use the MUI_INSTALLOPTIONS_DISPLAY_RETURN or MUI_INSTALLOPTIONS_SHOW_RETURN macro. The return value will be added to the stack, so you can use the Pop command to get it.


Originally posted by pengyou
From the MUI ReadMe:
If you need the InstallOptions return value (success, back, cancel, error), use the MUI_INSTALLOPTIONS_DISPLAY_RETURN or MUI_INSTALLOPTIONS_SHOW_RETURN macro. The return value will be added to the stack, so you can use the Pop command to get it.
Thanks, I now have this:

# Display the page.
!insertmacro MUI_INSTALLOPTIONS_DISPLAY "screen1.ini"
!insertmacro MUI_INSTALLOPTIONS_SHOW_RETURN
Pop $R0 ;Get the return value
MessageBox MB_OK "$R0"
Call Save
But now all I get is: error... When I press cancel or next. Also tried to search for examples that use "MUI_INSTALLOPTIONS_SHOW_RETURN", but didn't find them.

I suggest you read the MUI ReadMe again ;)

If you want to get the return value, use

MUI_INSTALLOPTIONS_DISPLAY_RETURN instead of MUI_INSTALLOPTIONS_DISPLAY
or
MUI_INSTALLOPTIONS_SHOW_RETURN instead of MUI_INSTALLOPTIONS_SHOW

Try

 # Display the page.
!insertmacro MUI_INSTALLOPTIONS_DISPLAY_RETURN "screen1.ini"
Pop $R0 ;Get the return value
MessageBox MB_OK "$R0"
Call Save
The mathtest.nsi example uses MUI_INSTALLOPTIONS_DISPLAY_RETURN