Almost all has suffered one or more levels of discomforts while switching to WiX from well established toolsets for creating packages such as InstallShield. And when one discovers that there is no GUI avalable in the WiX toolset then one thing comes to each and everyindividual's mind "oh my god .. now what will i do about Dialog boxes". To resolve this, people behind WiX has released certain customized dialog sequence libraries along with the binaries for WiX. you can read about using those in here.
In this post i ll be talking about one of the Common Dialog that has not been provided by WiX community and whose probability of existence in any installer is very near to 1. Yes, i am talking about the SQL Login DialogBox. Though we can use certain tools provided by various developers across the globe such as WiXEdit.
Even using it is very easy, but time consuming. So here is the XML for the SQL Login Dialog and the procedures to follow while adding it.
<!-- sql login-->
<Dialog Id="MySqlLogin" Width="370" Height="270" Title="!(loc.VerifyReadyDlg_Title)">
<Control Id="Next" Type="PushButton" X="236" Y="243" Width="56" Height="17" Default="yes" Text="!(loc.WixUINext)">
</Control>
<Control Id="Back" Type="PushButton" X="180" Y="243" Width="56" Height="17" Text="!(loc.WixUIBack)">
</Control>
<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>
<Control Id="Description" Type="Text" X="25" Y="23" Width="280" Height="15" Transparent="yes" NoPrefix="yes" Text="Select database server and provide the credentials." />
<Control Id="Title" Type="Text" X="15" Y="6" Width="200" Height="15" Transparent="yes" NoPrefix="yes" Text="{WixUI_Font_Title}Database Server">
</Control>
<Control Id="BannerBitmap" Type="Bitmap" X="0" Y="0" Width="370" Height="44" TabSkip="no" Text="!(loc.InstallDirDlgBannerBitmap)" />
<Control Id="BannerLine" Type="Line" X="0" Y="44" Width="370" Height="0" />
<Control Id="BottomLine" Type="Line" X="0" Y="234" Width="370" Height="0" />
<Control Id="FolderLabel" Type="Text" X="20" Y="50" Width="290" Height="25" Text="[SQLLOGINDLGDESCRIPTION]" />
<Control Id="SQLSERVERcontrol" Type="ComboBox" X="20" Y="80" Width="240" Height="15" Property="LISTBOXPROP">
</Control>
<Control Id="BrowseSqlServer" Type="PushButton" X="270" Y="80" Width="56" Height="17" Text="B&rowse">
<Publish Event="SpawnDialog" Value="spawndialogDBservers" Order="3">1</Publish>
</Control>
<Control Id ="textEnterthecredentials" Type="Text" X ="20" Y ="120" Width ="300" Height ="15" Text="Please provide the credentials for the server selected above."/>
<Control Id="textUsername" Type="Text" X="20" Y="140" Width="50" Height="15" Text="Login ID:" />
<Control Id="Username" Type="Edit" X="90" Y="140" Width="150" Height="15" Property="SQLUSERNAME" TabSkip="no">
</Control>
<Control Id="textPassword" Type="Text" X="20" Y="160" Width="50" Height="15" Text="Password:" />
<Control Id="Password" Type="Edit" X="90" Y="160" Width="150" Height="15" Property="SQLPASSWORD" Password="yes">
</Control>
</Dialog>
And for the spawn dialog for getting the list of SQL Servers in the network is here.
WiX dont provide ComboBox by default into MSI db the time of building. But you can add it using the Customtable node as:
<!--spawn dialog for database servers on network-->
<Dialog Id="spawndialogDBservers" Width="370" Height="270" Title="!(loc.VerifyReadyDlg_Title)">
<Control Id="text" Type ="Text" X="20" Width ="300" Y ="20" Height ="30" Text="From the list of servers below, select the database server you would like to target."></Control>
<Control Id="DBLISTBOX" Type ="ListBox" Property="LISTBOXPROP" X="20" Y="60" Width="300" Height="170" Sorted="no" Indirect="no" >
</Control>
<Control Id="OK" Type ="PushButton" Default="yes" X="160" Y="240" Width="56" Height="17" Text="&OK">
<Publish Event ="EndDialog" Value ="Return" Order ="2"/>
</Control>
</Dialog>
Am not sharing the code for getting SQL servers on network here, as it is very easy and you can use DTF feature of the WiX to find that out.
Moreover, dont forget to add the code for validation to this as well on various controls.
<CustomTable Id="ComboBox" >
<Column Id="Property" Category="Identifier" PrimaryKey="yes" Type="string" Width="4" Nullable="no"/>
<Column Id="Order" Category="Integer" Type="int" PrimaryKey="no" Nullable ="no" Width="4"/>
<Column Id="Value" Category="Formatted" Type="string" PrimaryKey="no"/>
<Column Id="Text" Category="Text" Type="string" PrimaryKey="no" Nullable="yes"/>
<Row>
<Data Column="Property">localhost</Data>
<Data Column="Order">0</Data>
<Data Column="Value">localhost</Data>
<Data Column="Text">localhost</Data>
</Row>
</CustomTable>
happy WiXing...