Var mycaption
Caption $mycaption
Function .onInit
${If} $whichProduct == 1
StrCpy $mycaption $(Product1Caption)
${Else}
StrCpy $mycaption $(Product2Caption)
${EndIf}
FunctionEnd
In the above example, the titlebar is always in English, regardless of what language the user's system is and what the rest of the installer pages appear in.
I assume because LangStrings are not loaded until after .onInit.
However, because changes to $mycaption after .onInit are ignored, it is not possible to set a dynamic caption that respects multiple languages.
It would be better if $mycaption could be set during .onGUIInit
Further more, manually changing the title bar text using SendMessage is fruitless - because as each new page is loaded the title bar gets reset to the saved caption.
Perhaps all of this could be solved by adding a SetCaption instruction, which sets the saved caption and updates the title bar text at the same time?
I suspect the exact same problems affect Name, although I haven't tested.
To clarify, the problem is when you change $LANGUAGE during .onInit and use variable captions - becuase changes to $LANGUAGE aren't picked up until after .onInit, at which point it is too late to change the captions.
You can always change the caption at runtime. IIRC, it works like this:
SendMessage $HWNDPARENT ${WM_SETTEXT} 0 'STR:New caption title'
Last edit: idleberg 2017-03-28
Unfortunately that has to be called on every single page and the change is visible by the end user - the old caption appears, then changes to the desired caption a split second later - the change is very noticeable, particularly on slower machines.
Set the caption to " " if you want to perform this hack.
Have you tried pre / show functions?
Yes
With a patch like
it does seem to react to changes to $mycaption in .onGuiInit but I assume there is a reason why it is not coded this way. The background window will not be updated but that should be easy to fix.
Last edit: Anders 2017-03-31
This fully reproduces the issue
Last edit: Anders 2017-05-16