hide textboxes on checkbox checked in WiX - wix

Is it possible to hide textboxes on checkbox checked in WiX?

Thanks for your comments, the first comment helped me. It is done like this:
<Control Id="LoginTextBox" Type="Edit" Text="CM2" Height="17" Width="200" X="150" Y="198" Property="Login">
<Condition Action="hide" >CreateDBUsers<>1</Condition>
<Condition Action="show" >CreateDBUsers=1</Condition>
</Control>

This is a very old question, and the answer is: Yes it is possible.
I finally get how this works based on this blog post and Bogdan Verbenets's answer. To elaborate already chosen answer, this snippet based on his answer might help you understand more:
<Control Id="AnyCheckBox" Type="CheckBox" Height="17" Width="10" X="150" Y="180" Property="CreateDBUsers" CheckBoxValue="1" />
<Control Id="LoginTextBox" Type="Edit" Text="CM2" Height="17" Width="200" X="150" Y="198" Property="Login">
<Condition Action="hide"><![CDATA[CreateDBUsers<>"1"]]></Condition>
<Condition Action="show">CreateDBUsers="1"</Condition>
</Control>
Which the above code work the same as below:
<Control Id="AnyCheckBox" Type="CheckBox" Height="17" Width="10" X="150" Y="180" Property="CreateDBUsers" CheckBoxValue="0" />
<Control Id="LoginTextBox" Type="Edit" Text="CM2" Height="17" Width="200" X="150" Y="198" Property="Login">
<Condition Action="hide"><![CDATA[CreateDBUsers<>"0"]]></Condition>
<Condition Action="show">CreateDBUsers="0"</Condition>
</Control>
Please pay attention to CheckBoxValue which its value determine what you going to write in the condition text.
Note:
It better to use <![CDATA[ write_something_here ]]> when you need to write conditional involving < (less than equal) or > (greater than equal).
It might more proper to use string ("1", "0") in condition text since CheckBoxValue actually use string data type, you can check at official documentation. Although this is not mandatory.
Check box is definitely quite a something different in WiX.

Related

WiX: how to expand the variable which is used in the localized string?

WiX.
This is my localized String:
<String Id="SelectInstallDir_WARNING_Text">Don't select the "$(env.ProgramData)\Autodesk\ApplicationPlugins\ProxyTools.bundle\" variant if you will use AutoCAD 2012, because its bundle-autoloader don't monitor of that directory.</String>
I use that string here:
<Control Id="warning_acad2012_text" Type="Text" X="10" Y="170" Width="350" Height="60"
Transparent="yes" NoPrefix="yes">
<Text>{\DlgFont10_important}!(loc.SelectInstallDir_WARNING_Text)</Text>
</Control>
But I see that $(env.ProgramData) variable wasn't expanded.
How can I fix it?
Assuming you want the current value at install time, instead of the value from the build machine, you should Windows Installer's formatting. Specifically you should reference a directory property such as "... [CommonAppDataFolder] ..." or an environment variable such as "... [%ProgramData] ...".

Storing Checkbox value in a Property Wix 3.7

Currently I am working on a simple project in which i have to modify an xml file using user input in WIX 3.7. Everything goes fine except in case of checkbox.
I have created a Property and then using that property in a checkbox type of control. I need that if the checkbox is checked then Node value will be modified to 1 and if not then 0.
Below is the code i have used.
<Property Id="ISPATH" Secure="yes"></Property>
<Control Id="checkBox1" Type="CheckBox" Height="18" Width="67" X="104" Y="108" Text="Is-Path" Property="ISPATH" CheckBoxValue="1" >
</Control>
<util:XmlFile Id="ModifyPath" Action="setValue" Permanent="yes" ElementPath="/DataBaseSettings/IsPath"
File="[#Settings]" Value="[ISPATH]" SelectionLanguage="XSLPattern" Sequence="1" />
No Change is seen in ISPATH property.
Any Suggestions????

checking the registration number entered by user

I was trying to use a custom dll for checking the registration number entered by user, but I run every time into “magic” behavior. In the tutorial examples http://wix.tramontana.co.hu/tutorial/events-and-actions/whats-not-in-the-book the custom action is running after ‘CostFinalize’, which normally should be before file copying procedure, but it turns out that the action runs before the very first dialog box with License Agreement appears. I have tried to solve the problem by assigning an action on the event of clicking the “next” button in registration Dialog
<Publish Dialog="MySerialCheckDlg" Control="Next" Event="DoAction" Value="CheckingPID">1</Publish>
<Publish Dialog="MySerialCheckDlg" Control="Next" Event="SpawnDialog" Value="InvalidPidDlg">PIDACCEPTED = "0"</Publish>
...
<CustomAction Id="CheckingPID" BinaryKey="CheckPID" DllEntry="CheckPID" />
<Binary Id="CheckPID" SourceFile="serialcheck.dll" />
In dll, using MsiGetProperty (hInstall, "PIDKEY", Pid, &PidLen); does not get the PIDKEY value from msi specified in MySerialCheckDlg UI
<Control Id="CDKeyEdit" Type="Edit" X="45" Y="159" Width="220" Height="16" Property="PIDKEY" Text="[PIDTemplate]" />
And in the msi the PIDACCEPTED property is not been checked in the line
<Publish Dialog="MySerialCheckDlg" Control="Next" Event="SpawnDialog" Value="InvalidPidDlg">PIDACCEPTED = "0"</Publish>
Thus, the InvalidPidDlg does not appear, and the installation process continues further.
Can you please specify the order of WiX Action Sequence, or maybe specify any other approach which can be used in this situation.
There are two sequences: InstallExecuteSequence and InstallUISequence. If MSI runs with full UI, it executes actions from InstallUISequence; in case where no UI is shown, these actions are skipped. Actions from InstallExecuteSequence are executed during the installation process, with or without UI.
First of all, is your PIDKEY property tied to an edit control? You should something similar in the dialog where you ask users to type in PIDKEY:
<Control Id="PidKeyEdit" Type="Edit" X="45" Y="105" Width="220" Height="18" Property="PIDKEY" Text="{80}" />
Type could be either Edit or MaskedEdit. Publish elements should be associated with Next button control on the dialog:
<Control Id="Next" Type="PushButton" X="236" Y="243" Width="56" Height="17"
Default="yes" Text="Next">
<Publish Event="DoAction" Value="CheckingPID">1</Publish>
<Publish Event="SpawnDialog" Value="InvalidPidDlg">PIDACCEPTED = "0"</Publish>
</Control>
Run your installation with verbose logging to see how actions are executed, and how property values change:
msiexec /i your-product.msi /lv* your-product.log

Conditional choose between two exit dialog when using WIX's InstallDir UI extension

I would like to have two different exit dialogs based on the version of the VersionMsi property in order to utilize the hyperlink control for the exit dialog. More information here.
I'm using a customized version of WIX's InstallDir_UI extension for my install process. Since I would like to optionally support the hyperlink control if available, I have created two different dialogs:
<Dialog Id="NonHyperlinkExit" Width="370" Height="270" Title="!(loc.ExitDialog_Title)">
<Control Id="Finish" Type="PushButton" X="236" Y="243" Width="56" Height="17" Default="yes" Cancel="yes" Text="!(loc.WixUIFinish)" />
...
<Control Id="HowToLink" Type="Text" X="135" Y="175" Width="220" Height="10" Transparent="yes" NoPrefix="yes" Text="!(loc.InfoUrl)" />
...
</Dialog>
<Dialog Id="HyperlinkExit" Width="370" Height="270" Title="!(loc.ExitDialog_Title)">
<Control Id="Finish" Type="PushButton" X="236" Y="243" Width="56" Height="17" Default="yes" Cancel="yes" Text="!(loc.WixUIFinish)" />
...
<Control Id="HowToHyperLink" Type="Hyperlink" X="135" Y="175" Width="220" Height="10" Text="!(loc.InfoLink)" />
...
</Dialog>
I've then modified the UI publish statements to support those dialogs to something like this:
<Publish Dialog="NonHyperlinkExit" Control="Finish" Event="EndDialog" Value="Return" Order="998"><![CDATA[VersionMsi < "5.0"]]></Publish>
<Publish Dialog="HyperlinkExit" Control="Finish" Event="EndDialog" Value="Return" Order="999"><![CDATA[VersionMsi >= "5.0"]]></Publish>
When running this, I get the following errors:
error LGHT0204: ICE20: Exit dialog/action not found in 'AdminUISequence' Sequence Table.
error LGHT0204: ICE82: This action HyperlinkExit has duplicate sequence number -1 in the table InstallUISequence
So I've tried to modify the InstallUISequence instead, but with little help. Tried this:
<InstallUISequence>
...
<Show Dialog="NonHyperlinkExit" Before="HyperlinkExit"><![CDATA[VersionMsi < "5.0"]]></Show>
<Show Dialog="HyperlinkExit" OnExit="success"><![CDATA[VersionMsi >= "5.0"]]></Show>
</InstallUISequence>
But this only give me the following error:
error LGHT0177: The InstallUISequence table contains an action 'NonHyperlinkExit' that is scheduled to come before or after action 'HyperlinkExit',
which is a special action which only occurs when the installer terminates.
These special actions can be identified by their negative sequence numbers.
Please schedule the action 'NonHyperlinkExit' to come before or after a different action.
Any ideas on how to create conditional exit dialogs would be appreciated.
MSI supports only one exit dialog per state (e.g., success). You could use a custom action instead that showed the the appropriate dialog.
You can also use a custom action to dynamically inject controls onto a dialog only when it's supported. See:
Dynamic Windows Installer UI

How to inspect a CustomAction's property (Wix)?

I am trying to put together a small 'prerequisites' dialog in Wix to give confidence to the users that they have all of the required things needed to run my software:
For example, I have a need for Managed DirectX, so I look for some DLLs:
<Property Id="MANAGED_DIRECTX">
<DirectorySearch Path="$(env.SystemRoot)\Microsoft.NET\DirectX for Managed Code\1.0.2902.0" Depth="0" Id="MDXDir">
<FileSearch Name="Microsoft.DirectX.dll"/>
</DirectorySearch>
</Property>
<Property Id="MANAGED_DIRECTX_DIRECTINPUT">
<DirectorySearch Path="$(env.SystemRoot)\Microsoft.NET\DirectX for Managed Code\1.0.2902.0" Depth="0" Id="MDXInputDir">
<FileSearch Name="Microsoft.DirectX.DirectInput.dll"/>
</DirectorySearch>
</Property>
I also have a CustomAction to combine my condition logic:
<CustomAction Id="SetManagedDirectXInstalled"
Property="MANAGED_DIRECTX_INSTALLED"
Value="NOT([MANAGED_DIRECTX] = '') AND NOT ([MANAGED_DIRECTX_DIRECTINPUT] = ''")/>
This CustomAction is sequenced:
<InstallExecuteSequence>
<Custom Action="SetManagedDirectXInstalled" After="AppSearch" />
<RemoveExistingProducts After="InstallInitialize" />
</InstallExecuteSequence>
What I should now be able to do is use "MANAGED DIRECTX INSTALLED" to do something, e.g.
<Control Id="NoManagedDirectX" Type="Text" X="20" Y="50" Width="300" Height="60" Transparent="yes" NoPrefix="yes" Hidden="yes">
<Text>Microsoft Managed DirectX (MDX) for DirectX 9.0 is NOT installed</Text>
<Condition Action="show">NOT MANAGED_DIRECTX_INSTALLED</Condition>
</Control>
<Control Id="ManagedDirectX" Type="Text" X="20" Y="50" Width="300" Height="60" Transparent="yes" NoPrefix="yes" Hidden="yes">
<Text>Microsoft Managed DirectX (MDX) for DirectX 9.0 is correctly installed</Text>
<Condition Action="show">MANAGED_DIRECTX_INSTALLED</Condition>
</Control>
It doesn't matter what I do, the condition is always false (e.g. not installed) even when I know the files are there. Using the msiexec command with /l*vx does not show the MANAGED DIRECTX INSTALLED property anywhere.
When a <Condition> is used with the following, it successfully prevents installation (although I no longer want to block installs in this case, just advise).
<Condition Message="You must have Microsoft Managed DirectX (MDX) for DirectX 9.0 installed">
MANAGED_DIRECTX AND MANAGED_DIRECTX_DIRECTINPUT
</Condition>
How can I trace/debug this (or what have I done wrong?)
EDIT - I'm now certain that my CustomAction is not even being called, setting it to the following is not showing expected results either!
<CustomAction Id='SetManagedDirectXInstalled'
Property='MANAGED_DIRECTX_INSTALLED'
Value='Something hard-coded'/>
or
<CustomAction Id='SetManagedDirectXInstalled'
Error='Some error should show!'/>
I think I may have found the answer, but I can't try it until I'm next at my development PC.
It appears I have to compare the values to TRUE/FALSE (or empty string) not just expecting it to work as boolean (Source)
In these expressions, you can use
property names (remember that they are
case sensitive). Non-existent property
names will be treated as empty
strings. The logical value of a
property reflects whether it has been
set—meaning that you cannot check for
a logical value by simply using the
property:
PROPERTY
This will evaluate to true if the property has been set and has any
value, even if this value is false.
NOT PROPERTY
This will evaluate to true if the property has not been set at all.
PROPERTY = TRUE
PROPERTY = FALSE
This is the proper way to check the value of a logical property.
To debug, use a verbose log file. It will show you the states of your Properties as they change. You should then be able to evaluate the Condition with that knowledge
I answered this same question not too long ago here. A Condition that uses the Property name is a test for existence. An existence test for a Property evaluates to true if the Property has any value at all. If you want to check the value of a Property you need to do so explicitly.