Dan
Posts: 4489
Joined: Wed Apr 24, 2013 3:51 pm

Display themed dialog instead of standard Launch Condition dialog

Tue Jun 29, 2021 1:38 pm

Hello,

When using custom themes, in case the package has any launch condition defined and the launch condition gets fired during installation, the dialog does not have the UI of the theme, which may not look nice.

In this case, you need to substitute the funcionality using custom dialogs.

Let's consider the following test case: Prevent installation on machines that have less that 32GB of RAM.

If we were using the default MSI theme, the launch condition would be something as this:
Standard MSI LC.PNG
Standard MSI LC.PNG (124.65 KiB) Viewed 13960 times

However, if using a custom theme e.g. Vivid, the dialog will not inherit the same layout, and it would look something as below:

Standard MSI LC on custom theme.PNG
Standard MSI LC on custom theme.PNG (56.21 KiB) Viewed 13960 times


The dialog cannot be further customized.


To overcome this, you can disable the launch condition from the Launch Conditions view. The good news is that Advanced Installer can detected and fill a property with the detected RAM from the target machine if the property is used in a condition field. For the case of detected installed RAM, the property is AI_DETECTED_PHYSICAL_MEMORY.

When enabling a launch condition a search operation is performed by Advanced Installer. The good news, is that you can also force the search if just using any of those properties in a Condition field, e.g. in the Condition field to condition a custom action execution, the condition field of a component or feature etc.

In our case, we will display a dialog and condition the dialog appeareance based on the value of AI_DETECTED_PHYSICAL_MEMORY.



Let's swtich to Surface theme.

We will display a dialog informing the user that the installation cannot proceed on machines that have less than 32 GB of RAM.

For this, please follow the below steps:

1) Select the Next from the InstallDlg
2) Go to the Published Events tab and add a new event
3) Select the Display a specific child dialog event with the below options:

Display a specific child event dlg.PNG
Display a specific child event dlg.PNG (112.92 KiB) Viewed 13960 times

Notice the added condition in the Condition field.


After this step, you need to make sure that the newly aded event is the the last in the list, at the bottom in the event list for the Next control.

This is required as the events of diaplying dialogs are executed bottom up and only the first that has the condition true is executed.
Events order.PNG
Events order.PNG (57.48 KiB) Viewed 13960 times

4) The newly added dialog should be liek below:

Default SpawnDlg.PNG
Default SpawnDlg.PNG (55.71 KiB) Viewed 13960 times


Design the dialog per your scenario. In our case, we will name the dialog LCDialog. Also, a single OK button will be added. The dialog won't allow the user to move forward with the installation, but it won't close the installation. e.g. if the argument will be different e.g. Exit the installer will move to FatalDlg while having the default Return argument will keep displaying the InstallDlg.


LCDialog.PNG
LCDialog.PNG (80.76 KiB) Viewed 13960 times


When the launch condition gets fired the user will be prompted with the below dialog:

LC Running.PNG
LC Running.PNG (49.51 KiB) Viewed 13960 times

As you can see, the launch condition has the same layout, and most of all you have full access to customize it, whatever you like.



Now, we handled the case when the installation is done through the UI. It's time to prevent the installation if the user is trying to install the app silently, or passing the /qb flag to avoid displaying dialogs.



To prevent the installation when a condition is true, you can just add the Display an error message predefined custom action. Use the same Condition: AI_DETECTED_PHYSICAL_MEMORY < 32768


Please note that the setup will set the AI_DETECTED_PHYSICAL_MEMORY property with the RAM in MB.

Here's how the custom action should be customized:


CA Props.PNG
CA Props.PNG (101.47 KiB) Viewed 13960 times


So, this is one approach to display a custom dialog based on a condition. In our case, we've been using the predefined AI_DETECTED_PHYSICAL_MEMORY property. If you are using other launch condition but you don't know for sure what is the property that is used by the setup, you can check the Launch Conditions table.

LC Table.PNG
LC Table.PNG (133.11 KiB) Viewed 13960 times



The sample project is attached to this thread, so if you are interested to take a look directly at my project, you are more than welcome to download the project file.


Let us know for similar scenarios!
Attachments
Demo App LC.aip
(37.94 KiB) Downloaded 362 times
Dan Ghiorghita - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Sample Projects”