- NSIS Discussion
- Radiobuttons and directory page
Archive: Radiobuttons and directory page
l_d_allan
12th January 2006 08:22 UTC
Radiobuttons and directory page
I want to have a customized MUI directory page, and I'm unclear the best/simplest way to proceed.
MyApp is part of a larger "family of apps" that can share resources, and there are three legitimate places to install the app ...
* based on the environment variable FAMILY_PATH
* based on where another app in the "family" was installed
* default if neither of the two above are present (which would be the case if MyApp is the first app in the "Family" to be installed.)
For example, the environment variable FAMILY_PATH might contain
X:\Test\Family
The app sibling.exe might be located in:
C:\Program Files\Sibling
The installer for sibling.exe will leave "bread crumbs" in the registry that indicate where it was installed. The installer for MyApp can detect the InstallDir of sibling.exe
If the environment variable isn't defined and the sibling.exe hasn't been installed, then the myapp.exe would by default be installed in:
C:\Program Files\MyApp\myapp.exe
The Directory page would be dynamically built based on the presence or absence of the environment variable and the sibling.exe program.
It might look something like the following ( circle O indicates radio button):
---------------------------
Do you want to install the app based on:
O - FAMILY_PATH = X:\Test\Family
O - sibling.exe = C:\Program Files\Sibling
O - Other directory .... default = C:\Program Files\MyApp
------------------------------
The "other directory" would be a normal Type=DirRequest with a preloaded default.
There could be one, two, or three radio buttons, depending on whether FAMILY_PATH was defined, or a registry entry for the InstallDir of sibling.exe was found.
kichik
12th January 2006 13:59 UTC
I'd edit the INI file on runtime, according to the presence of the "bread crumbs" and disable invalid options. To disable a control, write DISABLED to its FLAGS value.
l_d_allan
12th January 2006 14:31 UTC
Any sample code somewhere on how to do that?
What I'd like to end up with is illustrated in the attached screen-shot that is based on the MUI directory page. The Type=DirRequest field would be disabled unless its radiobutton was selected.
My impression is that it is possible to actually edit a dialog used by the MUI or "classic" nsis ... but that seems pretty advanced .... is there documentation and/or sample code that illustrates how to do this?
kichik
12th January 2006 14:41 UTC
It's very simple. Use WriteINIStr or MUI_INSTALLOPTIONS_WRITE.
l_d_allan
12th January 2006 15:53 UTC
Thanks for your help (and patience) with this less than nsis expert trying to do something maybe over my head.
I'm fuzzy on how to have the Type=DirRequest field be disabled unless its associated RadioButton is selected (see screen-shot from previous post). Is there something like .onSelChange that would apply to a RadioButton on a custom page?
Also, is there an explanation / documentation / sample code on modifying the MUI Directory page to accomplish the equivalent of what I'm trying to do?
Or is it likely to be simpler to build a custom page and invoke it instead of the Directory page?
(Or is this the kind of thing that a plug-in would be used for .... I can see how to do this with a Win32 dialog (or using MFC) but I have very little awareness of plug-ins and how they are used and developed.)
The other approach would be to have RadioButtons in the ComponentsPage (is that possible?). However, I haven't figured out how to have a selection in the ComponentsPage influence the choice in the DirectoryPage.
I would like to set some flag that the user picked "Install In Same Directory as FAMILY_PATH environment variable" on the ComponentsPage, but this seems to happen "too late" to modify the contents of the Type=DirRequest field on the DirectoryPage.
kichik
12th January 2006 16:27 UTC
To disable a control, write DISABLED to its FLAGS value. You can see how it's done in Examples\InstallOptions\testnotify.nsi.
Modifying the internal directory page requires editing the UI (Contrib\UIs\modern.exe) using Resource Hacker and then handling all of the logic yourself, using FindWindow, GetDlgItem and SendMessage in the pre and leave callback functions of the page.
Showing a pages according to section selection is possible. There's a wiki page about this.
A plug-in would work as well... The choice is up to you. Whatever fits your needs the best. If I were you, I'd have a custom page with two radio buttons for the first two options, and a directory page (which might be skipped) to get the custom directory. The internal directory page has some features which would be hard to imitate using InstallOptions, such as the free and required space.
l_d_allan
12th January 2006 17:30 UTC
If I were you, I'd have a custom page with two radio buttons for the first two options, and a directory page (which might be skipped) to get the custom directory.
Thanks for the guidance. I only work with nsis about once or twice a year, and it takes me a while to "shake off the rust" and try to get back "up to speed." As the years add up for this "older newbie", that takes longer and longer. You do a wonderful job of support.
The other approach would be to have RadioButtons in the ComponentsPage (is that possible?).
I'm still curious if it is possible to have three mutually exclusive RadioButtons in the Components page. Your wiki page reference would be useful then to "react" to the end-users choice.
kichik
12th January 2006 17:34 UTC
It's possible, take a look at Examples\one-section.nsi.