Browse Dialog - Changing Directory |
Your installation contains one or more features, each of which may have an "installation" directory associated with it. The feature's directory can be modified via the "CustomizeDlg" dialog (as can other feature attributes). The following in an example of this dialog:
The "Browse" button in the above dialog changes the directory for the selected feature. If its unavailable then directory modification is not available with this feature.
The following shows one way to allow feature selection of the "SOME_DIR" directory via the current feature (you could also specify the directory when creating the feature):
<$DirectoryTree Key="SOME_DIR" DIR="C:\Program Files\DefaultDir" Change=".">
If you find that varying one directory effects another's location then you should read the "Altering one Directory also effects Others" section.
Adding Directory Selection Buttons |
As mentioned above feature selection is generally better however you might not wish to display this reasonably complex dialog to the user.
The following is a simplest code I could come up with to demonstrate the use of the pre-existing "BrowseDlg" dialog to change a directories location.
The button could be placed on any existing (or new) dialog. You might want to put it next to a text or entry field containing the value etc.
;---------------------------------------------------------------------------- ;--- Macro to add buttons --------------------------------------------------- ;---------------------------------------------------------------------------- #( #define DIALOG_BROWSE_BUTTON ;--- What is the button going to be called? ----------------------------- #evaluate+ ^@@BrowseButtonId^ ^'BrowseButton.<?Unique>'^ ;--- Add the button to a dialog (will use "SetupTypeDlg") ------------------- <$Table "Control"> #( <$Row Dialog_="{$Dialog=^<$Dialog?>^}" Control="<$@@BrowseButtonId>" Type="PushButton" X="{$X}" Y="{$Y}" Width="{$Width}" Height="17" Attributes="3" Text="{$Text=^Change^}" Help="{$ToolTip=^^}|" > #) <$/Table> ;--- What happens when user presses the button? ----------------------------- <$Table "ControlEvent"> ;--- The "BrowseDlg" dialog uses the "_BrowseProperty" property --------- #( <$Row Dialog_="{$Dialog=^<$Dialog?>^}" Control_="<$@@BrowseButtonId>" Event="[_BrowseProperty]" Argument="{$Dir}" ;;Set _BrowseProperty = DirectoryName Condition="1" Ordering="1" ;;Step 1 > #) ;--- Now invoke the existing "BrowseDlg" dialog ------------------------- #( <$Row Dialog_="{$Dialog=^<$Dialog?>^}" Control_="<$@@BrowseButtonId>" Event="SpawnDialog" ;;Model dialog (sits on top this dialog Argument="BrowseDlg" Condition="1" Ordering="2" ;;Step 2 > #) <$/Table> #) ;---------------------------------------------------------------------------- ;--- Define the directory we will allow to be changed via the button -------- ;---------------------------------------------------------------------------- <$DirectoryTree Key="TEST_DIR_PROPERTY1" Dir="c:\TMP\dir1"> <$DirectoryTree Key="TEST_DIR_PROPERTY2" Dir="[ProgramFilesFolder]\dir2"> ;---------------------------------------------------------------------------- ;--- Create test dialog to test the above button macro ---------------------- ;---------------------------------------------------------------------------- #ifdef REMOVED_LicenseAgreementDlg ;;Only exists if the dialog has been removed... #define InsertAfter WelcomeDlg #else #define InsertAfter LicenseAgreementDlg #endif <$Dialog "Test Directoy Browse Buttons" INSERT="<$InsertAfter>"> ;--- Add 2 buttons (you;d normally probably use a text field with current values) --- #( <$DIALOG_BROWSE_BUTTON X="50" Y="50" Width="90" Text="Change Dir 1" Dir="TEST_DIR_PROPERTY1" ToolTip="Change directory 1" > #) #( <$DIALOG_BROWSE_BUTTON X="50" Y="70" Width="90" Text="Change Dir 2" Dir="TEST_DIR_PROPERTY2" ToolTip="Change directory 2" > #) <$/Dialog>
The above is only a basic example showing all the hard work, you may not like the resulting dialogs title or some of the text. You could make a near duplicate of the "BrowseDlg" (only changing those bits you need to).