Archive: Changing Root for DirRequest


Changing Root for DirRequest
An InstallOptions related question: is it possible to change the 'Root' value for a DirRequest control without reinitializing the page? Like, when you want to change 'State' (e.g. to append \MyProg after the user selects a dir), it's not enough to change it in .ini, you also need to use SendMessage to display the new string in the box. But 'Root' is not some element for which you can get a HWND, so I'm clueless.


I have used the DirRequest control in one of my setups. You can two things. Switch to using (!include nsDialogs.nsh). This targets the somewhat complicated programming method with using InstallOptions for custom dialogs. The tutorial is quite promising. If you have only one custom dialog, it is worth a try. The next problem you will be facing with InstallOptions, could be not a problem with nsDialogs.

Or you paste some code into your reply and I try to give you advice looking for similarities in my code. Actually I did not completely understand what you are trying to do. Please show your goal with examples and your problems as well.


I realize that switching to MUI2 would probably be the best solution but right now I don't have time nor the will to explore nsDialogs, so let's drop that one.
As for InstallOptions:
I've built a custom page for shortcuts selection. It uses DirRequest to select a Start menu folder. The user can also select whether it will be created for all or for current user. Default is set to current, so if the user clicks the 'All users' RadioButton, the script needs:
SetShellVarContext All
!insertmacro MUI_INSTALLOPTIONS_WRITE "shortcuts.ini" "Field 13" "Root" "$SMPROGRAMS"
But InstallOptions doesn't reload values from .ini so it will not take effect unless user reinits the page (i.e. goes <Back and then Next> again). This limitation is generally not much of a problem, you activate the change by getting HWND of the control and using SendMessage or EnableWindow, depending on what you need. But as I said, you can't do that for 'Root', it's not a page element and it has no HWND. I guess it's only handled internally by the plugin but I thought I'd ask anyway. My workaround for the problem is creating two separate DirRequest controls. I'm not completely happy with this solution but it's functional.
Wrote to Santa to bring me money so I have spare time to play around with nsDialogs.