Yet Another WiX Tutorial Part 3: Customizing the UI dialogs
Introduction
In a previous post I showed you how to use the UIExtensions library to add predefined user interfaces to you installer. These UIExtensions are easy to use, but what if none of these suit your needs. It is possible to customize the selected UI Extension and it is quit easy to do.
The following example will show you have to remove the LicenseAgreementDlg from the UI sequence of the WixUI_InstallDir extension.
Steps
Get the source code for the UIExtension
First thing you need to do is get the sources for the version of WiX you are using. After you have downloaded them, you van browse to the UIExtension folder to get the wxs fragment file that contains the extension
<SOURCE FOLDER>\src\ext\UIExtension\wixlib
When you open the extension WiX file (in this case WixUI_InstallDir) you will see a fragment with the ID used by the UIRef node.
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"><Fragment><UI Id="WixUI_InstallDir">
The fragment contain a set of DialogRef nodes that refer to dialogs defined in fragment files in the same folder, and a series of Publish nodes, that define to order of the dialogs.
Add the fragment to you WiX script
Now select the complete UI node and add it to you WiX script.
<UI Id="WixUI_InstallDir"><TextStyle Id="WixUI_Font_Normal" FaceName="Tahoma" Size="8" /><TextStyle Id="WixUI_Font_Bigger" FaceName="Tahoma" Size="12" /><TextStyle Id="WixUI_Font_Title" FaceName="Tahoma" Size="9" Bold="yes" /><Property Id="DefaultUIFont" Value="WixUI_Font_Normal" /><Property Id="WixUI_Mode" Value="InstallDir" /><DialogRef Id="BrowseDlg" /><DialogRef Id="DiskCostDlg" /><DialogRef ... /><Publish Dialog="BrowseDlg" Control="OK" Event="DoAction" Value="WixUIValidatePath" Order="3">1</Publish><Publish Dialog="BrowseDlg" Control="OK" Event="SpawnDialog" Value="InvalidDirDlg" Order="4"><![CDATA[WIXUI_INSTALLDIR_VALID<>"1"]]></Publish><Publish> ... </Publish></UI>
Change the Dialog order
Now find the part where the LicenseAgreementDlg is Published. If you look at the dialog published before and the dialog Published after the LicenseAgreementDlg you will see that they are filling in events for two important controls, Next and Back.
<Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="LicenseAgreementDlg">1</Publish>and<Publish Dialog="InstallDirDlg" Control="Back" Event="NewDialog" Value="LicenseAgreementDlg">1</Publish>
To skip the LicenseAgreementDlg, we need to change the values of the Publish node to the appropriate dialog values.
Notice that we changed the values of the Publish node from LicenseAgreementDlg to the previous and next dialog ID. You can now remove the LicenseAgreementDlg Publish nodes if you want, or leave them to change back later.<Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="InstallDirDlg">1</Publish>and<Publish Dialog="InstallDirDlg" Control="Back" Event="NewDialog" Value="WelcomeDlg">1</Publish>
Happy Coding.
Martijn.
Comments