possible way to disable controls at runtime? - wix

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";
}

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>

Wix Custom Action Property Not Immediately Available

I have a Wix VBScript Custom Action that sets a Property, and then a publish event that is supposed to trigger based on the value of the set property. The issue seems to be that the property is not being set and in turn not triggering the next publish event. Has anyone successfully done something similar?
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:hsi="http://schemas.hyland.com/wix/UtilityExtension">
<Fragment>
<Property Id="FOO" Value="0" Secure="yes" />
<CustomAction Id="Test3" Script="vbscript">
<![CDATA[
MsgBox Session.Property("FOO")
]]>
</CustomAction>
<CustomAction Id="Test2" Script="vbscript">
<![CDATA[
MsgBox "Test"
]]>
</CustomAction>
<CustomAction Id="Test1" Script="vbscript">
<![CDATA[
Session.Property("FOO") = "1"
]]>
</CustomAction>
</Fragment>
<Fragment>
<UI>
<DialogRef Id="WarningModalDlg"/>
<Dialog Id="BaseLawsonWebServerDlg" Width="370" Height="270" Title="Lawson LOB Broker Relay Setup">
<Control Id="label" Type="Text" X="20" Y="50" Width="200" Height="16" Text="Test" TabSkip="yes" Transparent="yes" />
<Control Id="Next" Type="PushButton" X="236" Y="243" Width="56" Height="17" Default="yes" Text="!(loc.WixUINext)">
<Publish Order="1" Event="DoAction" Value="Test3">1</Publish>
<Publish Order="2" Event="DoAction" Value="Test2">FOO = "1"</Publish>
<Publish Order="3" Event="DoAction" Value="Test1">1</Publish>
</Control>
<Control Id="Back" Type="PushButton" X="180" Y="243" Width="56" Height="17" Text="!(loc.WixUIBack)"/>
<Control Id="Cancel" Type="PushButton" X="304" Y="243" Width="56" Height="17" Cancel="yes" Text="!(loc.WixUICancel)">
<Publish Event="SpawnDialog" Value="CancelDlg">1</Publish>
</Control>
</Dialog>
</UI>
</Fragment>
</Wix>
Event="DoAction" Value="Test1" fires, I've tested it. Event="DoAction" Value="Test2">FOO = "1" does not hit. Then Event="DoAction" Value="Test3">1</Publish> definitely hits and shows the message box with the default value.
Thanks ahead of time!
I figured it out! I was so used to the reverse order of UI Dialog Publish events that I did the same thing for Control publish events.
Control Publish events move in the the order of 1 to x.
The publish events should look like this instead:
<Publish Order="1" Event="DoAction" Value="Test1">1</Publish>
<Publish Order="2" Event="DoAction" Value="Test2">FOO = "1"</Publish>
<Publish Order="3" Event="DoAction" Value="Test3">1</Publish>

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>

Based on CheckBox value show the WIX Dialog

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>