een
18th April 2011 12:02 UTC
change cancel button text if setup fails
I would like to change the cancel button text if my setup fails at the MUI_PAGE_INSTFILES. I tried
Section "A"
/* ... setup stuff ... */
GetDlgItem $4 $HWNDPARENT 2 /* 1 = Next, 2 = Cancel, 3 = Back */
${If} $0 != ''
/*Error*/
IfSilent +3
MessageBox MB_OK|MB_ICONSTOP "Installation failed"
SendMessage $4 ${WM_SETTEXT} "0" "Close"
Abort 'Error message'
${EndIf}
SectionEnd
but it does not work. How can I do it?
thanks
een
T.Slappy
18th April 2011 14:38 UTC
You are using WM_SETTEXT wrong. try this:
SendMessage$4 ${WM_SETTEXT} "STR:Close" "STR:Close"
een
18th April 2011 15:38 UTC
Thanks but this did not help. Here is my complete Script:
!include "MUI2.nsh"
>!define MUI_ABORTWARNING
>!insertmacro MUI_PAGE_INSTFILES
>!insertmacro MUI_PAGE_FINISH
>!insertmacro MUI_LANGUAGE "English"
>Name "NoName"
>OutFile "Setup.exe"
>InstallDir "$EXEDIR"
>Section "A"
GetDlgItem $4 $HWNDPARENT 2 /* 1 = Next, 2 = Cancel, 3 = Back */
SendMessage $4 ${WM_SETTEXT} "STR:Close" "STR:Close"
MessageBox MB_OK|MB_ICONSTOP "Installation failed"
/* SendMessage $4 ${WM_SETTEXT} "STR:Close" "STR:Close" */
Abort 'Error message'
/* SendMessage $4 ${WM_SETTEXT} "STR:Close" "STR:Close" */
>SectionEnd
>
While the message box is active I can see a gray "Close" button at the main window. But as soon as I close the message box the button text goes back to "cancel". I also tried the SendMessage comand at the uncommented positions but it did not solve the problem.
I am using NSIS v2.46 advanced logging build.
T.Slappy
19th April 2011 07:09 UTC
At this moment it is impossible to do...
Installer really needs the .onAbort callback!!!
The problem is that some call overwrite the text on Cancel button after I change it...
Only way to change it is to copy your text into cancel button variable:
StrCpy $(^CancelBtn) "Close"
but this is not allowed from code...
Afrow UK
19th April 2011 10:02 UTC
You can use MiscButtonText and use a variable for the Cancel button text with its initial value set to $(^CancelBtn).
Stu