简体   繁体   中英

Sizing a WIX dialog to fit dynamic text

I have a [PREREQUISITES_MISSING] property set in a custom action (C#). Its value is a string containing a list of prerequisites that were deemed to be missing through various Powershell/Registry checks.

I display a dialog before the default 'Welcome' dialog in the UISequence, on the condition that at least one prerequisite is missing.

My issue:

The list of pre-requisites may be long or short. If it is long, it gets cut off. If I set the dialog size to be very large, it may be mostly blank space in many cases. Is it possible to do either of the following:

  • Dynamically set the width/height of the dialog based on the contents
  • Include a scrollbar on the dialog should the contents exceed the width/height
<Dialog Id="PrereqsMissingDlg" Width="260" Height="85" Title="!(loc.InstallDirDlg_Title)" NoMinimize="yes">
    <!--Other controls removed for brevity-->
    <Control Id="PrereqsMissingTxt" Type="Text" X="48" Y="15" Width="200" Height="30" TabSkip="no" Text="[PREREQUISITES_MISSING]" />
</Dialog>

Neither of those two solutions are possible. However a ScrollableText (RTF) should do what your looking for. Note you can't used formatted types such as [PREREREQS_MISSING] but you can use dyamic UI as described on my blog here:

http://blog.iswix.com/2008/07/dynamic-windows-installer-ui.html

Just adapt the SQL to update the database row that contains the stock RTF for the control you define in WiX. You can figure this out by looking at the built MSI using ORCA.

Following up on Christopher's answer, here is the code required to answer my question:

Custom Action (C#)

[CustomAction]
public static ActionResult VerifyPrerequisites(Session Session)
{
    //(prereq checking code removed for brevity)

    //Retrieve and remove the dialog record
    Database db = Session.Database;
    View view = db.OpenView("SELECT * FROM Control WHERE Dialog_='PrereqsMissingDlg' AND Control='PrereqsMissingText'");
    view.Execute();
    Record record = view.Fetch();
    view.Delete(record);

    //Convert the error messages to RTF
    System.Windows.Forms.RichTextBox rtb = new System.Windows.Forms.RichTextBox();
    rtb.Text = errorMsg;

    //Update the record with the missing prereqs text
    record.SetString("Text", rtb.Rtf);   

    //Insert the new record
    string sqlInsertSring = db.Tables["Control"].SqlInsertString + " TEMPORARY";
    view = db.OpenView(sqlInsertSring);

    view.Execute(record);
    view.Close();

    return ActionResult.Success;
}

Revised Dialog

<Dialog Id="PrereqsMissingDlg" Width="260" Height="85" Title="!(loc.InstallDirDlg_Title)" NoMinimize="yes">
    <!--Other controls removed for brevity-->
    <Control Id="PrereqsMissingText" Type="ScrollableText" X="48" Y="15" Width="200" Height="30" Sunken="yes">
        <Text></Text>
    </Control>
</Dialog

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM