Add custom radio buttons to set ALLUSERS property

寵の児 提交于 2021-02-08 05:12:00

问题


I would like to be able to set the ALLUSERS property to either blank for current user or 1 for all users using two radio buttons placed in the 'Destination Folder' dialog.

I understand that this is the code to run for current user:

<Property Id="AllUSERS" Value="{}"/>

and for all users:

<Property Id="AllUSERS" Value="1"/>

I've got this code to create the custom radio buttons:

<Control Id="RadioButtonGroupID" Type="RadioButtonGroup" X="30" Y="94" Width="305" Height="100" Property=" VARIABLETOSTORESTATE " Text="This is My Group">
    <RadioButtonGroup Property="VARIABLETOSTORESTATE">
    <RadioButton Value="1" X="0" Y="0" Width="200" Height="10" Text="State 1" />
    <RadioButton Value="2" X="0" Y="20" Width="200" Height="10" Text="State 2" />
    </RadioButtonGroup>
</Control>

However, I don't know where I should put this in my Wix code.

Any help would be great thanks.


回答1:


You need to create your own dialog window which will contain the radio buttons. Here is a good tutorial to start with : http://wix.tramontana.co.hu/tutorial/user-interface-revisited/a-single-dialog

Here is a minimalist example. With this, the UI of your installer will consist of only 1 dialog with your radio buttons and the button "install":

<UI>
  <Dialog Id="RbDlg" Width="370" Height="270" Title="[ProductName] Setup" NoMinimize="yes">
    <Control Id="RadioButtonGroupID" Type="RadioButtonGroup" X="30" Y="94" Width="305" Height="100" Property=" VARIABLETOSTORESTATE " Text="This is My Group">
    <RadioButtonGroup Property="VARIABLETOSTORESTATE">
    <RadioButton Value="1" X="0" Y="0" Width="200" Height="10" Text="State 1" />
    <RadioButton Value="2" X="0" Y="20" Width="200" Height="10" Text="State 2" />
    </RadioButtonGroup>
    </Control>

    <Control Id="Install" Type="PushButton" X="304" Y="243" Width="56" Height="17"
                Default="yes" Text="Install">
      <Publish Event="EndDialog" Value="Return" />
    </Control>
  </Dialog>
  <InstallUISequence>
    <Show Dialog="RbDlg" Before="CostInitialize" />
  </InstallUISequence>
</UI>

Of course you can add this dialog in an already existing Wix dialog set. Maybe you already call such an UI using for example :

<UIRef Id="WixUI_Mondo" />

Here is a good introduction : http://www.packtpub.com/article/windows-installer-xml-wix-adding-user-interface

Here are some hints to save you some time : in the above tutorial, note how each dialog calls another one with the "next" and "back" buttons :

<Publish Dialog="LicenseAgreementDlg" Control="Back" 
      Event="NewDialog" Value="WelcomeDlg">1</Publish> 
<Publish Dialog="LicenseAgreementDlg" Control="Next" 
      Event="NewDialog" Value="CustomizeDlg">LicenseAccepted = "1"</Publish> 

In your dialog, you can also create "next" and "back" buttons. Ofc the last dialog has a "Finish" button instead of "next".

There are many examples on the internet on how to skip the licence agreement dialog (like this one). Those are good basic examples on how to alter the install UI sequence. If you can understand such examples, then you'll have enough knowledge to add your custom dialog to the install UI sequence. It is not very difficult to learn, and quite powerful. Good luck !



来源:https://stackoverflow.com/questions/23658849/add-custom-radio-buttons-to-set-allusers-property

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!