"Support for disabling controls based on conditions"

Apr 4, 2013 at 5:21 PM

Is there support for hiding controls based on conditions?

I'd like to hide a checkbox on the options page...

Apr 4, 2013 at 5:27 PM
There is (by setting <control>State="hide") but it is not working and I have figured out why yet. Setting <control>State="disable" works.
Apr 4, 2013 at 9:15 PM
While investigating another problem I discovered that if you set HideWhenDisabled="yes" and then use <control>State="hide" you can hide the control.
Apr 4, 2013 at 9:30 PM
Can you provide an example of where I would add <control>?
Apr 4, 2013 at 10:11 PM
Something like this:
    <Variable Name="SomeControlState" Type="string" Value="disable" />
where "SomeControl" is the name of a control on the UI.
Apr 4, 2013 at 10:25 PM
For an example take a look at Bundle2.wxs and modify Bundle2Theme.xml so that BrowseButton2 has HideWhenDisabled="yes".
Apr 5, 2013 at 9:43 AM
Mmm... I'd already tried

<Variable Name="Checkbox1" Type="string" Value="disable" />

with the following in the XML:

<Checkbox Name="Checkbox1" X="170" Y="-51" Width="89" Height="17" TabStop="yes" FontId="3" HideWhenDisabled="yes">#(loc.Checkbox1)</Checkbox>

but it's still visible.

If I change the value to Hide, it's still visible...


Even if this does work, how can I conditionalise the state?

Apr 5, 2013 at 10:30 AM
You need the word State on the end of the control name, e.g. Checkbox1State.

You would need to set the value based on some other data e.g. registry read. This can be hard in native burn code which is were the BA Functions can be useful.
Apr 5, 2013 at 11:01 AM
Yes, that worked thanks.

On a different note, have you considered adding any disk space checking?

According to Rob, the values are in the generated embedded XML.
Apr 5, 2013 at 12:26 PM
Not something I have considered, it wouldn't be too hard to implement in a BA function. I am not aware of the values in the generated XML did Rob give any more information.
Apr 5, 2013 at 1:45 PM
Apr 5, 2013 at 2:00 PM
What Rob is saying is that the size of the install is available in the bootstrapper data XML (attribute InstalledSize), you should be able to write a BA function to read this and validate before install (probably using the OnPlan() interface). Nothing out of the box I am afraid.
Apr 5, 2013 at 3:22 PM
Also, is the extra functionality in this extension being merged into 3.8?

I think I've seen commits to this effect...

Apr 5, 2013 at 4:07 PM
Yes that is the plan, I still have a few bits to go.
Jul 25, 2013 at 3:10 PM
Any update on the merge?

Also, if I wanted to hide a control based on the OS... any neat suggestions?

Jul 25, 2013 at 10:10 PM
The merge in to 3.8 is complete.

No ideas regarding the OS other than using the BA functions.
Aug 1, 2013 at 9:13 PM
When you say BA functions, do you mean I need to enhance wixextba to handle conditions?
Aug 1, 2013 at 10:20 PM
No, you can create a supplemental C++ assembly to handle more complex tasks, see Bundle10.wxs for an example.
Aug 2, 2013 at 10:28 AM
Sorry to go on..

So in order to set the state of a control to disabled based on whether a variable exists or not (based on a registrysearch), I need to do the registrysearch and variable-set in OnDetect() in bafunctions.dll and then use that in the bundle?

Aug 2, 2013 at 3:21 PM
I've got this working more or less now...

Only thing I need the 'hide' state to work... did you ever work out why not?

I can see SW_HIDE is passed to ::ShowWindow but it's still visible...
Aug 2, 2013 at 5:35 PM
Afraid I never got that to work and don't really know why.