Based on CheckBox value show the WIX Dialog - wix

I have instakllation i have to show the Dialog based on the checkbox value. I have set the checkbox property as true initially.
<Property Id="CHECKBOX_1_PROP" Value="TRUE" />
And show the dialog based on the check box values. If it is true i have to show the Newdoalog_1 if it is false i have to show the Setup dialog
<Control Id="Next" Type="PushButton" X="236" Y="243" Width="56" Height="17" Text="[ButtonText_Next]" TabSkip="no" Default="yes">
<Publish Event="SetTargetPath" Value="APPDIR">INSTALL</Publish>
<Publish Event="NewDialog" Value="NewDialog_1">INSTALL AND CHECKBOX_1_PROP="TRUE"</Publish>
<Publish Event="NewDialog" Value="SetupTypeDlg">INSTALL</Publish>
</Control>
<Control Id="CheckBox_1" Type="CheckBox" X="25" Y="164" Width="211" Height="26" Property="CHECKBOX_1_PROP" Text="Do you want to install the Samples" CheckBoxValue="CheckBox" TabSkip="no" Hidden="yes">
<Condition Action="show">INSTALL</Condition>
</Control>
My Problem is always show the Setup Dialog that is False condition.
Pls help on this.

I'm guessing your checkbox isn't setting the string literal "TRUE", check-boxes completely delete the property when unchecked. Setting that property to any value ("0", "true", "false", "-1") would cause it to be checked. So ignore the value, just check if the property exists or not.
<Publish Dialog="MyDlg" Control="Next" Event="NewDialog" Value="CustomDlg1">PROP1</Publish>
<Publish Dialog="MyDlg" Control="Next" Event="NewDialog" Value="CustomDlg2">Not PROP1</Publish>

To get the SetupTypeDlg to only show when CHECKBOX_1_PROP <> "TRUE" the code should look something like this:
<Publish Event="NewDialog" Value="SetupTypeDlg"><![CDATA[INSTALL AND CHECKBOX_1_PROP<>"TRUE"]]></Publish>

Related

Wix installer refresh page after custom action

I am looking for way to refresh current page after custom action.
My code
<Control Id="Config" Type="PushButton" .../>
<Publish Event="DoAction" Value="SetConfiguration"></Publish>
</Control>
It can be after custom action, but I don't see that Session has such an opportunity, or just adding some Event to Control that will work.
Edit:
Ok I have somethink like this:
<Control Id="Config" Type="PushButton" X="120" Y="243" Width="56" Height="17" Default="yes" Text="Config" >
<Publish Event="DoAction" Value="SetConfiguration" Order="1"></Publish>
<Condition Action="disable">EndConfig = "true"</Condition>
<Condition Action="enable">EndConfig = "false"</Condition>
<Publish Event="NewDialog" Value="IISconfiguration2">EndConfig="true</Publish>
</Control>
But how to create NewDialog after return result custom acion. Because it now do it in this same time. Set order on 1 and 2 dont work.
Try this
<Control Id="Config" Type="PushButton" X="120" Y="243" Width="56" Height="17" Default="yes" Text="Config" >
<Publish Event="DoAction" Value="SetConfiguration">1</Publish>
<Condition Action="disable">EndConfig = "true"</Condition>
<Condition Action="enable">EndConfig = "false"</Condition>
<Publish Event="NewDialog" Value="IISconfiguration2">2</Publish>
</Control>
This is a known behavior in MSI native UI.
The best work around I have is to make a clone of the dialog and transition from the original to the clone dialog (or the clone to the original) so that it looks like the same dialog to the user but it's actually a different dialog and the data will be refreshed.
Example.
On SQLDlg1:
<Control Id="Test" Type="PushButton" Text="&Test" TabSkip="no" Default="yes" Height="17" Width="56" X="283" Y="195">
<Publish Event="NewDialog" Value="SQLDlg2">1</Publish>
<Publish Event="DoAction" Value="ValidateDatabase">1</Publish>
</Control>
On SQLDlg2:
<Control Id="Test" Type="PushButton" Text="&Test" TabSkip="no" Default="yes" Height="17" Width="56" X="283" Y="195">
<Publish Event="NewDialog" Value="SQLDlg1">1</Publish>
<Publish Event="DoAction" Value="ValidateDatabase">1</Publish>
</Control>
On the next dialog I also clear the property in case they click back.
<Publish Dialog="VerifyReadyDlg" Control="Back" Property="DatabaseValid" Value="{}">1</Publish>
<Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="SQLDlg">1</Publish>

Dialog sequence based on Registry Search

What I'm trying to do is if a certain registry value is not found on the machine, a custom dialog will be shown to them where they can choose the value that they want to add. The problem is when they select that value and click Next, then click Back, since the property relating to that registry is already filled, the custom dialog will not be shown anymore unless they re-run the installer. I hope I'm clear enough, here're the snippets of the code.
<Property Id="REG_VAL" Value="NoValueFound">
<RegistrySearch ... />
</Property>
<Component ...>
<RegistryValue Value="[REG_VAL]".../>
</Component>
<UI...>
<Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="ChooseValueDlg">
<![CDATA[(REG_VAL="NoValueFound")]]>
</Publish>
<Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="VerifyReadyDlg">
<![CDATA[(REG_VAL<>"NoValueFound")]]>
</Publish>
<Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="ChooseValueDlg">
<![CDATA[(REG_VAL="NoValueFound")]]>
</Publish>
<Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="WelcomeDlg">
<![CDATA[(REG_VAL<>"NoValueFound")]]>
</Publish>
</UI>
<UI>
<Dialog Id="ChooseValueDlg" ...>
<Control Id="rdoBtnGrp" Type="RadioButtonGroup" Property="REG_VAL" ...>
<RadioButtonGroup Property="REG_VAL">
<RadioButton Value="NoValueFound" .../>
<RadioButton Value="Value1" .../>
<RadioButton Value="Value2" .../>
</RadioButtonGroup>
</Control>
</Dialog>
</UI>
You need to save the results of the registry search into two properties and bind one of them to the UI for editing by the user and one used as conditions for the mutually exclusive control events. This way if you start off with both null the dialog gets displayed and then when the user enters data into one the other is still null and the dialog will still be displayed.
BTW I like to ditch the unneeded CDATA and use PROPERTY and Not PROPERTY. I think it's easier to read.

possible way to disable controls at runtime?

Is there a way to disable UI controls while I'm doing some actions like checking database availability? Now it's like this:
<Control Id="Next" Type="PushButton">
<Publish Event="DoAction" Value="CheckDBConnection" Order="3">
<![CDATA[SQL_SERVER <> "" AND SQL_USER <> "" AND SQL_PASSWORD <> ""]]>
</Publish>
<Publish Event="DoAction" Value="Confirm_OverwriteDatabase" Order="2"/>
<Publish Event="NewDialog" Value="VerifyReadyDlg" Order="1"/>
</Control>
When CheckDBConnection is executing, all controls are alive, but doesn't do anything. It will be more accurate to disable them while performing background action.
Use Conditions with enable\disable Actions, based on the desired properties:
<Control Id="{Id}" Type="{Type}">
<Condition Action="enable" ><![CDATA[SOMEPROPERTY = SomeValue]]></Condition>
<Condition Action="disable"><![CDATA[SOMEPROPERTY <> SomeValue]]></Condition>
</Control>
Thanks to #vitaliy-zadorozhnyy, I was able to come up with an extra weird code that I dont't understand myself. But it works.
...
...
<Property Id="DBCHECK_INPROGRESS" Value="0" />
<Property Id="DBCHECK_NOTINPROGRESS" Value="0" />
...
...
<Control Id="{Id}" Type="{Type}">
<Condition Action="enable"><![CDATA[DBCHECK_INPROGRESS <> 1]]></Condition>
<Condition Action="disable"><![CDATA[DBCHECK_INPROGRESS = 1]]></Condition>
</Control>
{insert those conditions for any control you want to disable during action}
...
...
<Control Id="Next" Type="PushButton">
<Condition Action="enable"><![CDATA[DBCHECK_INPROGRESS <> 1]]></Condition>
<Condition Action="disable"><![CDATA[DBCHECK_INPROGRESS = 1]]></Condition>
<Publish Event="DoAction" Value="SetInProgress">1</Publish>
<Publish Property="TEMP_INPROGRESS" Value="[DBCHECK_INPROGRESS]">1</Publish>
<Publish Property="DBCHECK_INPROGRESS" Value="[TEMP_INPROGRESS]" />
<Publish Event="DoAction" Value="CheckDBConnection"/>
<Publish Event="DoAction" Value="SetNotInProgress">1</Publish>
<Publish Property="TEMP_NOTINPROGRESS" Value="[DBCHECK_NOTINPROGRESS]">1</Publish>
<Publish Property="DBCHECK_NOTINPROGRESS" Value="[TEMP_NOTINPROGRESS]" />
{other events}
</Control>
and custom actions (JScript) are simple:
function SetInProgress_CA() {
Session.Property("DBCHECK_INPROGRESS") = "1";
}
function SetNotInProgress_CA() {
Session.Property("DBCHECK_INPROGRESS") = "0";
}

WIX UI Property Change Not Publishing

I have a edit control in WIXUI that's bound to a property
<Property Id="WIXUI_FILESHAREDIR">FILESHAREDIR</Property>
and the UI
<Control Id="FileSharePathGroup" Type="GroupBox" Height="89" Width="352" X="8" Y="96" Text="File Share"/>
<Control Id="FileSharePathLabel" Type="Text" X="20" Y="114" Width="69" Height="13" Text="File Share Path"/>
<Control Id="FileSharePathEdit" Type="PathEdit" X="20" Y="126" Width="250" Height="16" Property="WIXUI_FILESHAREDIR" Indirect="yes" />
<Control Id="FileSharePathBrowse" Type="PushButton" X="280" Y="125" Width="56" Height="17" Text="Browse"/>
and the following Publish statements:
<Publish Dialog="ConfigurationDlg" Control="Back" Event="NewDialog" Value="InstallDirDlg">1</Publish>
<Publish Dialog="ConfigurationDlg" Control="Next" Event="NewDialog" Value="VerifyReadyDlg">1</Publish>
<Publish Dialog="ConfigurationDlg" Control="FileSharePathBrowse" Property="_BrowseProperty" Value="[WIXUI_FILESHAREDIR]" Order="1">1</Publish>
<Publish Dialog="ConfigurationDlg" Control="FileSharePathBrowse" Event="SpawnDialog" Value="BrowseDlg" Order="2">1</Publish>
When I use the browse button the FILESHAREDIR property ends up getting updated correctly. When I type into the text editor manually and hit Next, it doesn't and the FILESHAREDIR retains the incorrect default value at install time.
Am I missing a Publish statement?
You need to use the Property#Secure attribute to list the public property in the SecureCustomProperties property.

Checking on the click of next button whether the user has entered a value in textbox

I want to know how do I validate the entry in the textbox? I am making use of the wix toolset 3.5. What I mean is I should get a prompt or some message that says that you must enter the text (I have a name of the person here ) and the installation must not proceed without it.
You need to modify your UI element so that there is a conditional Publish tag that determines if the property attached to the TextBox is populated or not:
<Publish Dialog="NameSettingsDlg"
Control="Next"
Property="ErrorMessage" Value="You need to fill in your name!"
Order="1">
NOT NAME_PROPERTY
</Publish>
<Publish Dialog="NameSettingsDlg"
Control="Next"
Event="SpawnDialog"
Value="InvalidSettingsDlg"
Order="2">
NOT NAME_PROPERTY
</Publish>
<Publish Dialog="NameSettingsDlg"
Control="Next"
Event="NewDialog"
Value="VerifyReadyDlg">
</Publish>
where the "InvalidSettingsDlg" is defined as:
<Fragment>
<UI>
<Dialog Id="InvalidSettingsDlg"
Width="260"
Height="85"
Title="!(loc.InvalidSettingsDlg_Title)">
<Control Id="OK" Type="PushButton" X="102" Y="57" Width="56"
Height="17" Default="yes" Cancel="yes" Text="!(loc.WixUIOK)">
<Publish Event="EndDialog" Value="Return">1</Publish>
</Control>
<Control Id="Text" Type="Text" X="48" Y="22" Width="194" Height="30"
Text="[ErrorMessage]" />
<Control Id="Icon" Type="Icon" X="15" Y="15" Width="24" Height="24"
ToolTip="!(loc.InvalidSettingsDlgIconTooltip)" FixedSize="yes"
IconSize="32" Text="WixUI_Ico_Exclam" />
</Dialog>
</UI>
</Fragment>