WiX Customization dialog box

Source: Internet
Author: User
Tags cdata

Customize dialog box

Before we get started, let's look at what dialog boxes are included in the standard Wixui_mondo UI:

   
   
   
   
   
   

These standard dialogs have back and Next buttons, they are connected in a way that is similar to a doubly linked list, and the newly added dialogs need to be inserted into the doubly linked list; Here we need to add the Dbconfigdlg dialog box, and we need to redefine the link list to the next node.

First we create a Dbconfigdlg.wxs file with the following file contents:

<?xml version= "1.0" encoding= "Utf-8"?> <wix xmlns= "Http://schemas.microsoft.com/wix/2006/wi" > < fragment> <UI> <dialog id= "Dbconfigdlg" width= "370" height= "title=" [ProductName] [Set UP] "nominimize=" yes "> <control id=" Dbnamelabel "type=" Text "x=" "y=" "All" width= "$" height= "T" Abskip= "No" text= "database name:"/> <control id= "Dbnameedit" type= "Edit" x= "$" y= "" "Width=" 280 "height="  "Property=" DBNAME "text=" {200} "/> <control id=" Serverlabel "type=" Text "x=" GB "y=" 94 "width=" " height= "tabskip=" no "text=" Server (name or IP address): "/> <control id=" Serveredit "type=" Edit "x=" "y=" 10 9 "width=" 280 "height=" "property=" SERVERNAME "text=" {+} "/> <control id=" usernamelable "type=" Te
                XT "x=" y= "131" width= "280" height= "ten" tabskip= "no" > <Text> user name:</text>
           </Control>     <control id= "Usernameedit" type= "Edit" x= "32" y= "146" width= "280" height= "" "property=" Dbusername "text=
                Gt
                <control id= "Passwordlabel" type= "Text" x= "" y= "169" width= "$" height= "all" tabskip= "no" text= "Password:"/> <control id= "Passwordedit" type= "Edit" password= "yes" x= "" y= "184" width= "280" height= "" property= "Dbpassword "text=" {+} "/> <control id=" Testconnect "type=" pushbutton "x=" "y=" 206 "width=" "" "height=" T ext= "Test Connection (&amp;
                    T) "> <publish event=" DoAction "value=" Connectdb "order=" 2 ">1</Publish>
                <publish event= "Spawndialog" value= "Invaliddbdlg" order= "3" >1</Publish> </Control> <control id= "Back" type= "pushbutton" x= "" "y=" "243" width= "" "" height= "" text= "! (Loc.
       Wixuiback) "> <publish event=" newdialog "value=" Licenseagreementdlg ">1</Publish>         </Control> id= "Next" type= "pushbutton" x= "236" y= "243" width= "<control" height= "D" efault= "yes" text= "! (Loc. Wixuinext) "> <condition action=" Disable "><! [Cdata[connectsuccess <> "1"]]></condition> <condition action= "Enable" >connectsuc
                Cess = "1" </Condition> <publish event= "NewDialog" value= "Setuptypedlg" >1</Publish> </Control> <control id= "Cancel" type= "Pushbutton" x= "304" y= "243" width= "" "Heigh t= "cancel=" yes "text="! (Loc.
                Wixuicancel) "> <publish event=" spawndialog "value=" Canceldlg ">1</Publish> </Control> <control id= "BannerBitmap" type= "Bitmap" x= "0" y= "0" width= "370" height= "$" Tabski P= "No" text= "Wixui_bmp_banner"/> <control id= "Description" nowrap= "no" type= "Text" x= "All y=" Wi Dth= "280" Height= "transparent=" yes "noprefix=" yes "> <Text> continue installing the application requires the following information to ensure that the database is installed correctly and that the application is able to Run. </Text> </Control> <control id= "bottomline" type= "line" x= "0" y= "234" Width = "370" height= "0"/> <control id= "Title" type= "Text" x= "All" y= "6" width= "" "height=" "Transparen" t= "yes" noprefix= "yes" > <text>{/wixui_font_title} database Configuration </Text> </cont rol> <control id= "bannerline" type= "line" x= "0" y= "" width= "370" height= "0"/> < /dialog> <property id= "DBNAME" value= "test"/> <property id= "SERVERNAME" value= "(Local  ) "/> <property id=" dbusername "value=" sa "/> <property id=" Dbpassword "value=" 123456 " /> </UI> </Fragment> <Fragment> <UI> <dialog id= "Invali Ddbdlg "Width=" Height= "title=" [ProductName] [Setup] "nominimize=" yes "> <control id=" Return "type=" Pushbutton "x= "Y=" "width=" "height=" "default=" yes "cancel=" yes "text=" Back (&amp; R) "> <publish event=" enddialog "value=" Return ">1</Publish> </control > <control id= "connerror" type= "Text" nowrap= "no" x= "" y= "all Width=" 194 "height=" + "tabskip=" no " > <Text> database connection failed. </Text> <condition action= "Show" ><! [Cdata[connectsuccess <> "1"]]></condition> <condition action= "Hide" >connectsucce SS = "1" </Condition> </Control> <control id= "Connyes" type= "Text" nowrap= "n O "x=" y= "width=" 194 "height=" "tabskip=" no "> <Text> database connection was successful. </Text> <condition action= "show" >connectsuccess = "1" </condition> <condition action= "Hide" ><!
        [Cdata[connectsuccess <> "1"]]></condition> </Control> </Dialog> </UI> </Fragment> </Wix>

There are 2 dialog boxes in the code, consisting mainly of control , which is distinguished by the type attribute. Invaliddbdlg dialog box is used to pop up the connection prompt information, Dbconfigdlg dialog box accepts user input data, including text box, input box and button, etc. we can see each pushbutton type of Control Contains a publish tag that defines the event events property, and the Publish event property value contains the following possibilities:

1, DoAction, indicates that the button event executes an action action, and the Value property is the identity of the action

2, NewDialog, indicates that the button event will position the current interface to the new interface, the Value property is the identity of the interface

3, Spawndialog, indicates that the button event will pop up a modal dialog box, the Value property is the identity of the interface

4. If the publish tag does not have an event attribute defined, the property attribute must be defined, but not defined at the same time, and the property attribute is defined to indicate that the button event assigns a value to the property, and the value is the value set for the

Let's take a look at the effects of these buttons:

The Testconnect button contains two publish events, and the first event is the action that executes the CONNECTDB, which is the action that we defined in the previous section, and its second event is the popup invaliddbdlg dialog box. Prompt to connect to the database.

Back, next, and Cancel are standard buttons for the installation interface, and the publish event of the back button jumps to the Licenseagreementdlg Welcome screen, and the Next button's publish event jumps the interface to Setuptypedlg The installation type selection interface, the Next button contains two condition conditions, the first condition indicates that when connectsuccess <> "1", the Next button is disabled, The second condition indicates that when connectsuccess <> "0", the Next button will be activated; The publish event of the cancel will pop up the Canceldlg dialog box, and the Canceldlg dialog box is Windows Installer built-in, the user can choose whether to terminate or exit the installation.

The text and edit type Control is equivalent to the lable and textbox we are familiar with. The edit control must define the property so that we can reference it in either the installation process or the action, and be aware that the value of the property here correctly reflects the value of the edit box, while "text=" {32} " Only the length of the text box that is allowed to be entered, and if you want to assign the Control An initial value, the text setting does not work, and you need to display the definition property, such as:

<property id= "DBNAME" value= "Master"/>
The condition of the     connerror text box means that only if the connection fails, the condition of the Connyes text box indicates that it is only displayed at the time of the connection.          So, the new dialog has been created, and we need to modify the following sample.wxs, and the modified product section reads as follows:
<product ...> <package .../> ... <Feature...> </ feature> <binary id= ' connectdbclass ' sourcefile= ' $ (var.  Version)/samplecustomaction.ca.dll '/> <customaction id= ' launchfile ' filekey= ' filfoobarexe ' ExeCommand= ' return= ' asyncnowait '/> <customaction id= ' connectdb ' binarykey= ' connectdbclass ' DllEntry= ' ConnectDataBase '/&G
    
    T <ui id= "Mywixui_mondo" > <uiref id= "Wixui_mondo"/> <uiref id= "Wixui_errorprogresstext"/&gt
        
        ; <dialogref id= "Dbconfigdlg"/> <publish dialog= "Dbconfigdlg" control= "Testconnect" Property= "CONNECTIONST RING "value=" Data Source=[servername];user=[dbusername];p assword=[dbpassword];initial Catalog=[dbname];P
                  Ersist Security info=; " Order= "1" >not installed</publish> <publish dialog= "Licenseagreementdlg" Control= "Next" Event = "NeWdialog "value=" Dbconfigdlg "order=" 2 "> licenseaccepted =" 1 "</Publish> <publish Dialog= "Setuptypedlg" control= "Back" event= "NewDialog" value= "Dbconfigdlg" >1</Publish> <pu Blish dialog= "Exitdialog" control= "Finish" event= "DoAction" value= "LaunchFile" order= "1" >1</Publish> </   ui> <property id= "Wixui_installdir" value= "INSTALLDIR"/> </Product>
In the above code, we have customized a UI tag Mywixui_mondo, put the UI and interface elements to be referenced into this element, if you do not define a new UI tag, then the definition of the Publish event can only be defined under Dbconfigdlg.wxs UI. The Dbconfigdlg dialog defines the interface for back and next jumps, but it also defines only one end of the doubly linked list, and the Setuptypedlg back button and the Licenseagreementdlg's Next button row define the other end of the list.       All jump to the Dbconfigdlg interface. We also add a Publish event for the Testconnect button, which is used to assign a value to connectionstring, which can directly refer to the value of another property (in square brackets), whose order equals 1.       The order of Connectdb is equal to 2, stating that it is executed before connectdb; we only describe one usage here, and for setting up a connection string we can also not write this, generally we can get the properties of the input database connection string in the ' Connectdb ' method and then generate the connection string. Finally, we need to add the Dbconfigdlg dialog box when compiling and linking:
candle.exe-dversion=1.0.0  1.0.0/sample.wxs dbconfigdlg.wxs-out 1.0.0/
light.exe-loc WIXUI_ZH-CN.WXL  - Ext wixuiextension-out 1.0.0/sample.msi 1.0.0/sample.wixobj 1.0.0/dbconfigdlg.wixobj 
      We can see a way to add event handling to the control in WiX that allows for any UI, including the built-in UI, Wixui, and custom UI for Windows Installer. This allows us to control the installation process more easily. In the next section we will describe how to deploy the database at installation time.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.