I am using the MUI and want to set the MUI_PAGE_HEADER_TEXT and MUI_PAGE_HEADER_SUBTEXT dynamically so that a different message is shown at the end of Uninstall page if not all the files are deleted (common if there are user specific files that are not deleted by the uninstaller). I have tried a few different things, but without success.
In the MUI System.nsh file in macro MUI_FUNCTION_INSTFILESPAGE the call to MUI_ENDHEADER is immediately after MUI_PAGE_FUNCTION_CUSTOM LEAVE. This seems to exclude using the normal leave function to carry out any special setting of controls.
Any ideas how I can achieve what I want WITHOUT creating a custom page?
Bob
Dynamic setting of header text
7 posts
Solved by making a modified MUI System.nsh with the order of the calls to MUI_ENDHEADER and MUI_PAGE_FUNCTION_CUSTOM LEAVE reversed in the LEAVE function of MUI_FUNCTION_INSTFILESPAGE.
Then added the following Leave function with a user variable UninstErrorFlag that indicates if there is an error during the uninstall.
Anybody else got an opinion on this?
Bob
Then added the following Leave function with a user variable UninstErrorFlag that indicates if there is an error during the uninstall.
Maybe should consider reversing the order of the calls to MUI_ENDHEADER and MUI_PAGE_FUNCTION_CUSTOM LEAVE in the next update of the MUI to provide this additional flexibility. I can't see any downside.Function un.InstLeave
${If} $UninstErrorFlag == True
;Header text
StrCpy $MessageText "Uninstallation Not Fully Completed"
GetDlgItem $MUI_TEMP1 $HWNDPARENT 1037
SendMessage $MUI_TEMP1 ${WM_SETTEXT} 0 "STR:$MessageText"
;Header sub-text
StrCpy $MessageText "Some parts of ${MY_PROD} were not removed \
(see uninstall log for more details)"
GetDlgItem $MUI_TEMP1 $HWNDPARENT 1038
SendMessage $MUI_TEMP1 ${WM_SETTEXT} 0 "STR:$MessageText"
${EndIf}
FunctionEnd
Anybody else got an opinion on this?
Bob
You can use the MUI_HEADER_TEXT macro to set the header text.
An easier solution to the entire problem would be setting MUI_UNTEXT_FINISH_TITLE and MUI_UNTEXT_FINISH_SUBTITLE to a variable. That variable can then be changed in the leave function before it is actually used by MUI_ENDHEADER.
An easier solution to the entire problem would be setting MUI_UNTEXT_FINISH_TITLE and MUI_UNTEXT_FINISH_SUBTITLE to a variable. That variable can then be changed in the leave function before it is actually used by MUI_ENDHEADER.
kichik,
Excuse me if I don't understand this (I'm a newbie), but are these changes to the MUI System.nsh?
Bob
Excuse me if I don't understand this (I'm a newbie), but are these changes to the MUI System.nsh?
Bob
No, those are not changes to System.nsh. I copied the wrong define names. MUI_INSTFILESPAGE_FINISHHEADER_TEXT and MUI_INSTFILESPAGE_FINISHHEADER_TEXT are the two defines you need. Define those two right above the insertion of the uninstall instfiles macro. Instead of giving them real text, give them variables. In the leave function of the uninstall instfiles page, change those variables to the desired text.
That's brilliant! I had no idea you could !define to a variable, I'd assumed !define was only to a static value. It certainly isn't apparent from the documentation of !define.
How widely can this be used to modify internal parameters of the MUI via the Pre Show and Leave functions?
How widely can this be used to modify internal parameters of the MUI via the Pre Show and Leave functions?
Well, a define is just a "variable" of the compiler. Before the script is actually compiled, it's replaced with its contents. So, if you had the following script:
It will be translated to:!define a Sec
!define b "tion ab"
!define c c
${a}${b}${c}
SectionEnd
Nothing stops you from using variables in the defines too. In this case, MUI_INSTFILESPAGE_FINISHHEADER_TEXT is eventually used like this:Section abc
SectionEnd
!insertmacro MUI_HEADER_TEXT "${MUI_INSTFILESPAGE_FINISHHEADER_TEXT}" \
"${MUI_INSTFILESPAGE_FINISHHEADER_SUBTEXT}"This translates to:The text you've defined might be static, but SendMessage, which is used in the MUI_HEADER_TEXT macro, processes the text dynamically and replaces $0 with its current contents at runtime.!insertmacro MUI_HEADER_TEXT "$0" "some subtext"