foomigator
29th August 2011 10:30 UTC
Customize uninstaller Confirm page using MUI2 and nsDialogs
Hi everyone!
I'm stuck trying to add a checkbox on Uninstaller Confirm page. I'm using MUI2 and nsDialogs the following way:
define name customconfirm
>!include "MUI2.nsh"
>OutFile "${name}.exe"
>Name "${name}"
>InstallDir "$TEMPDIR"
>var unCheckbox
>Function un.MyConfirmShow
MessageBox MB_OK "Showing confirm page"
${NSD_CreateCheckbox} 50% 50% 100% 10u "&My checkbox"
Pop $unCheckbox
SetCtlColors $unCheckbox "" "ffffff"
>FunctionEnd
>!insertmacro MUI_PAGE_DIRECTORY
>!insertmacro MUI_PAGE_INSTFILES
>!define MUI_PAGE_CUSTOMFUNCTION_SHOW un.MyConfirmShow
>!insertmacro MUI_UNPAGE_CONFIRM
>!insertmacro MUI_UNPAGE_INSTFILES
>!insertmacro MUI_LANGUAGE English
Section
WriteUninstaller "$EXEDIR\uninst.exe"
>SectionEnd
>
When I run the generated uninstaller, it shows the message box I defined, which means my custom functions is called successfully, but there's no checkbox on confirm page. At first I thought that it might be hiddden for some reason, but Spy++ reveals there's no such control created on the page. Am I missing something essential?
T.Slappy
30th August 2011 07:15 UTC
Am I missing something essential?
Yes :)
You need to use nsDialogs to create WHOLE uninstall page!
Usign ${NSD_CreateCheckbox} somewhere in code is not enough.
Creating page should look like this:
nsDialogsPage
nsDialogs
::Create 1018
Pop $Dialog
${If} $Dialog == error
Abort
${EndIf}
${NSD_CreateCheckbox} 50% 50% 100% 10u "&My checkbox"
Pop $unCheckbox
nsDialogs::Show
FunctionEnd
>
But there is more to do, see docs:
http://nsis.sourceforge.net/Docs/nsDialogs/Readme.html
foomigator
30th August 2011 08:44 UTC
Originally posted by T.Slappy
Yes :)
You need to use nsDialogs to create WHOLE uninstall page!
Usign ${NSD_CreateCheckbox} somewhere in code is not enough.
That's mighty strange, because MUI2 readme clearly states the following:
"Modern UI pages can also be customized using custom functions."
and
"nsDialogs allows you to create custom pages or
customize existing pages directly from the script."
And this is true, at least partially ;) I was able to customize uninstaller finish page this way:
define name customfinish
>!include "MUI2.nsh"
>!include "FileFunc.nsh"
>OutFile "${name}.exe"
>Name "${name}"
>InstallDir "$TEMPDIR"
>var unCheckbox
>Function un.MyFinishShow
MessageBox MB_OK "Showing finish page"
${NSD_CreateCheckbox} 50% 50% 100% 10u "&My checkbox"
Pop $unCheckbox
SetCtlColors $unCheckbox "" "ffffff"
>FunctionEnd
>!insertmacro MUI_PAGE_DIRECTORY
>!insertmacro MUI_PAGE_INSTFILES
>!insertmacro MUI_UNPAGE_CONFIRM
>!insertmacro MUI_UNPAGE_INSTFILES
>!define MUI_PAGE_CUSTOMFUNCTION_SHOW un.MyFinishShow
>!define MUI_FINISHPAGE_RUN ; -- Strange, but this is REQUIRED to have any controls shown on Finish page.
!insertmacro MUI_UNPAGE_FINISH
>!insertmacro MUI_LANGUAGE English
Section
WriteUninstaller "$EXEDIR\un${name}.exe"
>SectionEnd
>
Naturally I thought this would be the way to modify uninstall Confirm page as well, but it seems it's not the case, so I decided to seek help here. I really don't want to reinvent the wheel (i.e. recreate the whole page) just to add a checkbox to one of pages existing by default :)
foomigator
30th August 2011 14:33 UTC
I actually solved the problem by following "Option A" solution found here.